我有一个名为co2a0000364.rd.002的文件
enter code here
# co2a0000364.rd
# 120 trials, 64 chans, 416 samples 368 post_stim samples
# 3.906000 msecs uV
#S1 obj,试验0 #FP1 chan 0 0 FP1 0 -8.921 0 FP1 1 -8.433
我想使用库“pickle”将已解析的变量存储在磁盘上。
>>> import pickle
>>> import pprint
>>> data= open("C:\\Users\\sonia\co2a0000364.rd.002")
>>> pprint.pprint(data)
<_io.TextIOWrapper name='C:\\Users\\sonia\\co2a0000364.rd.002' mode='r' encoding='cp1252'>
>>> data_string = pickle.dumps(data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot serialize '_io.TextIOWrapper' object