Python:源代码字符串不能包含空字节 [英] Python: source code string cannot contain null bytes

查看:432
本文介绍了Python:源代码字符串不能包含空字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Max OS X 10.10.3,在没有模块存在之前,我终于在Python 3中显示了graphics.py.

I'm using Max OS X 10.10.3, and I finally got the graphics.py to show in Python 3, before it was saying no module existed.

但是,现在当我尝试import graphicsfrom graphics import *时,我收到消息:

However, now when I try import graphics, or from graphics import *, I get the message:

"source code string cannot contain null bytes"

是否有任何Mac用户(使用Python 3)知道出了什么问题?有人使用过Zelle书和他的graphics.py模块吗?谢谢.

Does any Mac user (using Python 3) perhaps know what is wrong? Has anyone used the Zelle book and his graphics.py module? Thanks.

推荐答案

对于后代:我遇到了同样的问题,并使用

For posterity: I had the same problem and fixed it using,

sed -i 's/\x0//g' FILENAME

文件似乎以多种方式被弄乱了(以错误的结尾等);不知道怎么...

The file seemed to be messed up in numerous ways (wrong endings, etc); no idea how...

请参见 https://stackoverflow.com/a/2399817/230468

这篇关于Python:源代码字符串不能包含空字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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