Python - 保存上下文
我需要在退出之前保存程序的上下文...我已将所有需要的内容放入我之前创建的对象中,我多次尝试选择它,但没办法! 我不断遇到如下错误:
PicklingError: Can't pickle 'SRE_Match' object: <_sre.SRE_Match object at 0x2a969cd9c0>
OSError: [Errno 1] 不允许操作: [我引用的文件对于所有人都是 rwx]
我使用的代码是:
f = open ("/xxxx/yyyy/toto/titi/important_stuff//impo/tmp/contest.obj", 'w').close()
os.chmod("/xxxx/yyyy/toto/titi/important_stuff//impo/tmp/contest.obj", 0777)
f = open ("/xxxx/yyyy/toto/titi/important_stuff//impo/tmp/contest.obj", 'w')
pickle.dump(useCaseList, f)
有谁知道我该如何解决这些问题或有其他解决方案?
提前致谢
I need to save the context of the program before exiting ... I've put all the needed stuff to an object that I've previously created a I tried many times to picke it, but no way !!
I continuously have errors like :
PicklingError: Can't pickle 'SRE_Match' object: <_sre.SRE_Match object at 0x2a969cd9c0>
OSError: [Errno 1] Operation not permitted: [the file that I am referencing is rwx for all]
the code that I use is :
f = open ("/xxxx/yyyy/toto/titi/important_stuff//impo/tmp/contest.obj", 'w').close()
os.chmod("/xxxx/yyyy/toto/titi/important_stuff//impo/tmp/contest.obj", 0777)
f = open ("/xxxx/yyyy/toto/titi/important_stuff//impo/tmp/contest.obj", 'w')
pickle.dump(useCaseList, f)
Any knows how can I solve these problems or has another solution ?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅 python 文档 什么可以被 pickle 和 unpickled 。 您有无法腌制的对象。
See the python doc What can be pickled and unpickled. You have objects that can not be pickled.