解决:UnicodeDecodeError: gbk codec can t decode byte 0xaf in position 349: illegal multibyte sequenc

(一)报错原因:

不能识别GBK

(二)解决方法

定位报错代码:

def cfg_from_file(filename):
    """Load a config file and merge it into the default options."""
    import yaml
    with open(filename, 'r') as f:
        yaml_cfg = edict(yaml.full_load(f))

    _merge_a_into_b(yaml_cfg, __C)

修改代码如下:

def cfg_from_file(filename):
    """Load a config file and merge it into the default options."""
    import yaml
    with open(filename, 'r', encoding='UTF-8') as f:
        yaml_cfg = edict(yaml.full_load(f))

    _merge_a_into_b(yaml_cfg, __C)

你可能感兴趣的:(python,计算机视觉,学习,开发语言)