编程语言
首页 > 编程语言> > python琐碎知识

python琐碎知识

作者:互联网

文件读写的字符格式

import json
with open(str file ,'a' ,encoding=utf-8') as f:
	f.write(json.dumps(content ,ensure_ascii=False) +'\n')





补充

json.dumps()

	# transform dict data into str(/file)
json.dump( jsonData ,fileHandler )  -> str 
json.dumps( jsonData )  -->void
	# transform str in file into dict data
json.load( fileHandler)  -> dict
	# transform strData(json format) into dict data
json.loads( jsonData )  -> dict

标签:dump,python,into,知识,dumps,json,dict,str,琐碎
来源: https://blog.csdn.net/Hesy_H/article/details/90732877