Python:TypeError:描述符'strip'需要'str'对象但是收到'unicode'

时间:2017-03-24 14:20:31

标签: python packages

我正在学习如何使用包来处理MRS数据:http://suspect.readthedocs.io/en/latest/notebooks/tut01_intro.html

当我运行教程的前几行时:

import suspect
import numpy as np
from matplotlib import pyplot as plt

data = suspect.io.load_rda("Phantom1_svs_30.rda")
print(data)

我收到错误:

TypeError: descriptor 'strip' requires a 'str' object but received a 'unicode'

这是追溯:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-35cc3220407a> in <module>()
      1 
----> 2 data = suspect.io.load_rda("Phantom1_svs_30.rda")
      3 print(data)

C:\Users\VK\Anaconda2\lib\site-packages\suspect\io\rda.pyc in load_rda(filename)
     41         header_line = fin.readline().strip().decode('windows-1252')
     42         while header_line != ">>> End of header <<<":
---> 43             key, value = map(str.strip, header_line.split(":", 1))
     44             if key in rda_types["strings"]:
     45                 header_dict[key] = value

TypeError: descriptor 'strip' requires a 'str' object but received a 'unicode'

包文件中的错误是什么?

0 个答案:

没有答案