因为我通常使用ipython来开发正在开发的代码,所以我遇到了在将其导入ipython之后更改类的代码的情况.我想重新加载新的类定义而不重新启动ipython.问题是ipython中的重载功能仅适用于模块.
我搜索了这个问题的解决方案并找到了一个前一个线程: 如何在python shell中重新加载一个类?
但是,我按照那里的方法,但它没有奏效.我认为它在该线程中工作的原因是类名碰巧与模块名称相同,因此可以在sys.modules中找到它,因此可以删除.当类名与模块名不同时,该方法不起作用.
我想知道是否有这个问题的解决方案.谢谢!
我有一个Python脚本,它从文件中读取路径名列表,并使用gzip模块打开它们.它在Linux下运行良好.但是当我在Windows下使用它时,我在调用gzip.open函数时遇到了错误.错误消息如下:
File "C:\dev_tools\Python27\lib\gzip.py", line 34, in open
return GzipFile(filename, mode, compresslevel)
File "C:\dev_tools\Python27\lib\gzip.py", line 89, in __init__
fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
TypeError: file() argument 1 must be encoded string without NULL bytes, not str
Run Code Online (Sandbox Code Playgroud)
文件名应该是这样的
'G:\ ext_pt1\cfx33_50instr4_testset\cfx33_50instr4_0-99\cfx33_50instr4_cov\cfx33_50instr4_id0_cov\cfx33_50instr4_id0.detail.rpt.gz'
但是,当我打印文件名时,它打印出类似的东西
'■G:\ ext _ pt 1\cfx 3 3 _ 5 0 instr 4 _ testset\cfx 3 3 _ 5 0 instr 4 _ 0 - 9 9\cfx 3 3 _ 5 0 instr 4 _ cov\cfx 3 3 _ …