这段代码工作正常
allWriteNodes=nuke.allNodes("Write")
test = nuke.allNodes()
for index,each in enumerate(test):
wrtNodelst.insert(index,each.name())
print index, each.name()
sys.stdout.write(pickle.dumps(wrtNodelst))
quit()
except RuntimeError:
sys.stderr.write('could not find %s\n' % target_file)
raise
但是要在不同文件中读取的这一行会导致错误:
print pickle.loads(process.stdout.read())
给出IndexError:列表索引超出范围...任何想法可能导致它和读取pickle stdout数据? 回溯错误
Traceback (most recent call last):
File "\RenderUI.py", line 384, in execApp
print pickle.loads(process.stdout.read())
File "D:\Python26\lib\pickle.py", line 1374, in loads
return Unpickler(file).load()
File "D:\Python26\lib\pickle.py", line 858, in load
dispatch[key](self)
File "D:\Python26\lib\pickle.py", line 1203, in load_setitems
mark = self.marker()
File "D:\Python26\lib\pickle.py", line 874, in marker
while stack[k] is not mark: k = k-1
IndexError: list index out of range
答案 0 :(得分:0)
使用
print pickle.load(process.stdout)
这有用吗?
read可能不会返回整个字符串。
答案 1 :(得分:0)
这一行:
print index, each.name()
导致问题,因为它在发送pickle之前将调试输出发送到stdout
。