1

这段代码运行良好

    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 : list index out of range ... 知道是什么原因导致它读取腌制的标准输出数据吗? 回溯错误

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 
4

2 回答 2

0

采用

print pickle.load(process.stdout)

这行得通吗?

read 可能不会返回整个字符串。

于 2012-12-12T13:23:23.570 回答
0

这一行:

   print index, each.name()

导致问题,因为它在发送stdout泡菜之前发送调试输出。

于 2012-12-12T13:34:06.913 回答