wklken的笔记 2020-01-04
在后面加多:encoding=‘utf-8‘2Yaml读写:
import yamldef main():#读写解决中文:encoding=‘utf-8‘,allow_unicode=True data = {"GGG":{"kk":{"你好":["7","9"]}}}#生成text.yaml路径 with open("E:/pythonJIAO/test1/yaml/text.yaml","w",encoding=‘utf-8‘)as f: yaml.dump(data,f,allow_unicode=True)if __name__ == "__main__": main()