python上的cprofile编译错误

2024-09-27 17:40:49 发布

您现在位置:Python中文网/ 问答频道 /正文

使用python的cProfile,我对我的代码进行了cProfile,但是这个错误总是与compile()和null字符有关,我不太明白。在

错误消息是:

[cProfileV]: cProfile output available at http://127.0.0.1:4000 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/bin/cprofilev", line 9, in load_entry_point('CProfileV==1.0.6', 'console_scripts', 'cprofilev')() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cprofilev.py", line 217, in main code = compile(fp.read(), progname, 'exec') TypeError: compile() expected string without null bytes

是我的客户端代码有问题,还是服务器没有启动?在

提前谢谢你。在


Tags: 代码in消息错误linelibraryframework字符
2条回答

有人问过before.

无论如何,这个错误意味着您接收到的字符串不能很好地读取,因为它包含null。这意味着服务器已启动并正在响应,但您无法正确读取响应。这是因为它是另一种格式,很可能是JSON。尝试使用Python2.6及更高版本中包含的JSON模块;您可以看到它的一些示例,here.如果您向我们提供代码,我可以帮助您将应用程序转换为JSON友好的模块。:)

我相信这个错误是由cprofile和cprofilev的版本不匹配引起的。在

Cprofilev可以通过以下方式直接运行:

python -m cprofilev your_script.py

相关问题 更多 >

    热门问题