python
mimi_csdn
正在学习python的运维一枚
展开
-
python-requests,post json数据
https://www.cnblogs.com/xiehong/p/9050301.htmlhttps://www.cnblogs.com/miniren/p/7268816.htmlhttps://blog.csdn.net/qq_24373725/article/details/80692991python3 post数据在json文件中:1. for very larg...转载 2019-07-01 16:33:45 · 262 阅读 · 0 评论 -
python3 字符串拼接
1. 加号 2. 逗号 3. 直接连接 4. 格式化 5. join 6. 多行字符串拼接()1. 加号第一种,有编程经验的人,估计都知道很多语言里面是用加号连接两个字符串,Python里面也是如此直接用 “+” 来连接两个字符串;print 'Python' + 'Tab'结果:PythonTab2. 逗号第二种比较特殊,使用逗号连接两个字符串,如果两个字...原创 2019-08-15 11:25:25 · 438 阅读 · 0 评论 -
python小数点后补0,整数前补0,字符串前后补充空格
1.整数前补0a=1.333333344,将这个数保存为小数点后3位“%.03f” % a不过这样做返回的结果会变成一个字符串,显示为:'1.333'所以只要再在前面加个float()即可返回正常浮点数,即:float('%.03f'%a)但如果输入'%03f'%a这里没有了那个'.'返回结果就变为2.整数前补0print("%04...原创 2019-08-14 14:27:15 · 13659 阅读 · 0 评论 -
python3爬虫学习-记录
参考:https://ask.julyedu.com/article/323转载 2019-07-29 16:23:57 · 99 阅读 · 0 评论 -
python相关函数
1、json.dumps()和json.loads()是json格式处理函数(可以这么理解,json是字符串) (1)json.dumps()函数是将一个Python数据类型列表进行json格式的编码(可以这么理解,json.dumps()函数是将字典转化为字符串) (2)json.loads()函数是将json格式数据转换为字典(可以这么理解,json.loads()函数是将字符串转化为...原创 2019-06-24 14:39:48 · 406 阅读 · 0 评论 -
python-切片 list[0:10:1]
python-切片操作对象:list, tuple, string表达式:s[start,step]起始位置和结束位置均为索引,从0开始算,不包括结束位置step为步长,默认1变量s:可代表list, tuple, strings[0:3] 等价于 s[:3]s[1:3]s[0:-1] , s[:-1] 注意,-1代表最后一个元素,但是却是不包含-1的s[:] 全...转载 2019-06-26 18:33:44 · 6936 阅读 · 1 评论 -
Python中的排序sorted(d.items(), key=lambda x: x[1])
1、Python中对键值对进行输出和排序d= {'a':24,'g':52,'i':12,'k':33}# 以列表形式输出字典d的key# d.items()为字典d的键值对b1=[key for key,value in d.items()]print(b1)# 以列表的形式输出字典d的valueb2={value for key,value in d.items()}prin...转载 2019-06-26 18:29:26 · 6902 阅读 · 1 评论 -
python strip()函数和Split函数的用法总结
转载:https://www.cnblogs.com/yyxayz/p/4034299.htmlstrip函数原型声明:s为字符串,rm为要删除的字符序列.只能删除开头或是结尾的字符或是字符串。不能删除中间的字符或是字符串。s.strip(rm) 删除s字符串中开头、结尾处,位于rm删除序列的字符s.lstrip(rm) 删除s字符串中开头处,位于r...转载 2019-06-26 17:56:10 · 255 阅读 · 0 评论 -
python文件的打开和读取
f = open("文件名","打开方式")centent = f.read(size) f.readline(size) f.readlines()f.close()文件名需要有后缀打开方式: r-->只读w-->只写r+ -->读写...转载 2019-06-26 14:50:51 · 1750 阅读 · 0 评论 -
python 遍历列表(List)
#!/usr/bin/env python# -*- coding: utf-8 -*-if __name__ == '__main__': list = ['html', 'js', 'css', 'python'] # 方法1 print '遍历列表方法1:' for i in list: print ("序号:%s 值:%s"...原创 2019-08-16 17:01:08 · 258 阅读 · 0 评论