python编码问题:UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 68: illegal multibyte sequence

 

import yaml
def test_yaml():
    f = open('C:\hogwarts\Scripts\hogwarts-api\demo\yaml_data.yml')
    print(yaml.load(f))  

# 改进:
import yaml
def test_yaml():
f = open('C:\hogwarts\Scripts\hogwarts-api\demo\yaml_data.yml','rb')
print(yaml.load(f))
posted @ 2020-05-17 08:53  捷后愚生  阅读(668)  评论(0编辑  收藏  举报