#使用‘w’来提醒python用写入的方式打开 指定编码为
with open(filename,'w',encoding='utf-8') as fileobject: utf-8
fileobject.write('I love your name!'
'\nI love your cloth!'
'\nI love your shoes!'
'\nI love your hair!')
#使用‘a’来提醒python用附加模式的方式打开指定编码为
with open(filename,'a',encoding='utf-8') as fileobject: utf-8
fileobject.write('\nI an superman.')
如果不用with的写法
# 1. 打开
file = open("readme.txt", "a",encoding='utf-8' ) # a 以追加的方式打开 (默认以只读方式打开)
# 2. 写入文件
file.write("123 hello")
# 3. 关闭
file.close()
Python re模块的search方法
python按每行读取json文件
python报TypeError: 'str' object is not callable错误的解决办法
python3中json与JsonPath用法详解