我正在尝试使用 python 快速构建一个应用程序,大多数情况下一切正常,但是当我尝试运行一个读取 .p (pickle) 文件的函数时,我遇到了 I/O 错误。奇怪的是,当我在 shell 中运行相同的 python 程序时,它运行良好。
adam@adam-System-Product-Name:~/reskin/reskin$ quickly run
2, No such file or directory, newSnapShots.p
Traceback (most recent call last):
File "bin/reskin", line 36, in <module>
reskin.main()
File "/home/adam/reskin/reskin/__init__.py", line 31, in main
window = ReskinWindow.ReskinWindow()
File "/home/adam/reskin/reskin_lib/Window.py", line 37, in __new__
new_object.finish_initializing(builder)
File "/home/adam/reskin/reskin/ReskinWindow.py", line 36, in finish_initializing
self.set_app_data(builder)
File "/home/adam/reskin/reskin/ReskinWindow.py", line 43, in set_app_data
viewControler.app_by_name("firstVar")
File "/home/adam/reskin/reskin/back/viewControler.py", line 29, in app_by_name
app = applicationGetter.get_app_by_name(name)
File "/home/adam/reskin/reskin/back/applicationGetter.py", line 8, in get_app_by_name
for snap in savedSnaps:
TypeError: 'bool' object is not iterable
打印错误的函数:
def get_saved_snaps():
try:
with open('data/newSnapShots.p','rb') as snapFile:
savedSnaps = pickle.load(snapFile)
except IOError as e:
print "{0}, {1}, newSnapShots.p ".format(e.errno, e.strerror)
return False
return savedSnaps
文件树和 .p 位置
.
├── applicationGetter.py
├── applicationGetter.pyc
├── data
│ └── newSnapShots.p < file here
├── firstTimeSnapList.py
├── __init__.py
├── __init__.pyc
├── prosessCheckerv3.py
├── prosessScript.sh
├── viewControler.py
└── viewControler.pyc
快速使用 Cpickle 是否存在一些问题,我应该使用其他东西吗?先感谢您。