【发布时间】:2016-12-06 12:49:18
【问题描述】:
我有一个变量:
age_expectations = dictionary['looking_for']['age']
print type(age_expectations), age_expectations
输出是:
<type 'unicode'> 22‑35
当我试图用破折号拆分它时,我遇到了以下问题:
res = age_expectations.split('-')
print res
输出如下:
[u'22\u201135']
代替:
["22", "35"]
有什么问题?我已经尝试了许多编码和解码,但不确定它是如何工作的。问题是否来自分裂?
【问题讨论】:
-
可以描述更多细节,你是从文件中读取?
-
是的,我正在读取一个文件,其中包含在网站上抓取的数据
标签: python python-2.7 encoding split