python常识小记

来源:互联网 发布:淘宝补单方法 编辑:程序博客网 时间:2024/06/04 20:11
>>> print('\\\t\\')\       \>>> print(r'\\\t\\')\\\t\\

除法有两种

>>> 10 // 33

由list 转为str

text = ''.join(list)

由str转为list

list = str.split(string)

文件操作

    str = "测试文本"    path_dir = "D:/veriies/"    if not os.path.exists(path_dir):        os.makedirs(path_dir)    path = path_dir + "tian.txt"    fp = open(path, 'a', encoding="utf-8")    fp.write(str)    fp.close()
import Image  img = Image.open('example.jpg')  new_img= img.resize((w, h),Image.ANTIALIAS) # w代表宽度,h代表高度,最后一个参数指   定采用的算法  nwe_img.save('example-new.jpg',quality=100)