python - ValueError: source code string cannot contain null bytes

查看:5506
本文介绍了python - ValueError: source code string cannot contain null bytes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

问题如下:

station.py里面是python字典,我现在将station.py作为模块导入另一个模块中执行,出现了错误。

    from stations import stations
ValueError: source code string cannot contain null bytes

是valueerror,我找了一下出现这错误的都是typeerror,请问大家知道如何解决吗?

win7;模块导入正确;station里面只有一个字典。

谢谢==。

解决方案

使用下面的命令,去除stations.py文件中的null字符。这可能是你的文本编辑器错误引入的。

sed -i 's/\x0//g' <目标文件>

在这里则为:

sed -i 's/\x0//g' stations.py

补充,考虑到你是win系统,没有sed命令;建议你将文件中内容复制在其他地方,再重新复制回去。

这篇关于python - ValueError: source code string cannot contain null bytes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆