python3 ValueError: source code string cannot contain null bytes

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wm5920/article/details/80813607

从windows系统拷贝到linux系统pycharm中时经常会多一些空字符串,导致运行python脚本报错,“source code string cannot contain null bytes”
而pycharm中是无法察觉空字符串的(哪位朋友有解决办法,麻烦高诉我一下,不胜感激)
用vi打开文件才能看出来,多了很多“^@”,即空字符(ascii 码 0,在程序里一般写作”\0”),在 vim 里就显示成 ^@。
替换命令

:%s/\%x00//g

猜你喜欢

转载自blog.csdn.net/wm5920/article/details/80813607