简体   繁体   English

我正在转储管道数据,但是当我尝试使用pickle.loads读取时,出现错误

[英]i am dumping a piped data , but when i try to read using pickle.loads i get an error

this code works fine thats piping out 这段代码可以正常工作

    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

but this line that is going to read in different file causes error: 但是将在不同文件中读取的这一行会导致错误:

print pickle.loads(process.stdout.read())

giving IndexError : list index out of range... any idea what might be causing it and out to read pickled stdout data ? 给IndexError:列表索引超出范围...任何想法可能导致它并读取腌制的stdout数据吗? The Traceback error 追溯错误

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 

use 采用

print pickle.load(process.stdout)

does this work? 这有效吗?

read may not return the whole string. read可能不会返回整个字符串。

This line: 这行:

   print index, each.name()

Causes issues, as it is sending debug output to stdout before the pickle is sent. 导致问题,因为它在发送泡菜之前将调试输出发送到stdout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM