2023-04-12-- 读文件遇到的UnicodeDecodeError: ‘utf-8‘ codec can‘t decode bytes in position 1022-1023: un...

with tf.io.gfile.GFile(filepath, mode='r') as f:
df = pd.read_csv(f, dtype={
''xxxx": 'str',

    })

上述代码报
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 262142-262143: unexpected end of data
解决方案为将mode='r' 改为 mode='rb'

with tf.io.gfile.GFile(filepath, mode='rb') as f:
df = pd.read_csv(f, dtype={
''xxxx": 'str',

    })

你可能感兴趣的:(2023-04-12-- 读文件遇到的UnicodeDecodeError: ‘utf-8‘ codec can‘t decode bytes in position 1022-1023: un...)