我正在学习 Philip Klein 的“矩阵编码”。在第二章中,有一个绘制复数的例子
from plotting import plot
S = {2+2j, 3+2j, 1.75+1j, 2+1j, 2.25+1j, 2.5+1j, 2.75+1j, 3+1j, 3.25+1j}
plot(S, 4)
绘图模块:http://resources.codingthematrix.com
当我在终端中直接通过 python 运行代码时,它工作正常,但是当我将它作为单独的文件“$ python example.py”运行时,我得到这个错误:
gvfs-open: file:///tmp/tmpOYFVs8.html: error opening location: Error
when getting information for file '/tmp/tmpOYFVs8.html': No such file
or directory
不知道如何解决这个问题。尝试使用模块代码,但一无所获。
请您参考如下方法:
我检查了 plotting.py 的代码,发现在代码末尾注册了 atexit 事件,当你的程序退出时,它基本上会删除文件。所以当你调用它作为脚本时,python intrepreter exits 将实习调用atexit 注册删除文件。
def remove_at_exit(path):
atexit.register(os.remove, path)
可以直接注释掉plotting.py中92行的remove_at_exit方法的调用
