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

import yaml
def test_yaml():
    f = open('C:hogwartsScriptshogwarts-apidemoyaml_data.yml')
    print(yaml.load(f))  

# 改进:
import yaml
def test_yaml():
f = open('C:hogwartsScriptshogwarts-apidemoyaml_data.yml','rb')
print(yaml.load(f))
原文地址:https://www.cnblogs.com/Uni-Hoang/p/12903733.html