'decimal' codec can't encode character u'\ufeff' in position 0: invalid decimal Unicode string
这是由于txt文件保存方式是 UTF-8-BOM 而导致的
utf-8保存格式的txt文件encoding方式就是 encoding='utf-8'
utf-8-BOM保存格式的txt文件encoding方式是 encoding="UTF-8-SIG"
【'decimal' codec can't encode character u'\ufeff' in position 0: invalid decimal Unicode string】所以只要改成:with io.open(filepath,'r',encoding="UTF-8-SIG") as f: 就没有问题了
推荐阅读
- canvas(一)基本用法
- cannot|cannot be read or is not a valid ZIP file
- vue|vue canvas 手绘进度条动画
- canvas不过如此(一)
- 运行报错Cannot|运行报错Cannot find module '@babel/compat-data/corejs3-shipped-proposals’
- HTML|HTML canvas中translate()与rotate()的理解
- (4)Canal多实例使用
- iOS|iOS -Cannot synthesize weak property because the current deployment target does n
- 跟着项目学|跟着项目学 Android Canvas
- react|react Cannot find module 'node_modules/_react-scripts/config/webpack.config.dev