我有一个excel文件(xlsx)。这些值被读作unicode值。从excel读取unicode值到字符串
wb = xlrd.open_workbook('file.xlsx')
sh = wb.sheet_by_index(0)
first_column = sh.col_values(0)
snd_column = sh.col_values(1)
输出为以下形式:
first_column=['', u'here', u'here i am', u'where', u'where i am']
snd_column=['', u'20 km', ' ', u'10 km', u'23 km']
空单元被读取为正常空字符串。
如何以字符串形式直接输出/读取文件。像
first_coulmn=['', 'here', 'here i am', 'where', 'where i am']
snd_coulmn=['', '20 km', ' ', '10 km', '23 km']
我在寻找的是计算有效的方法。有小费吗?
为什么你需要*字节字符串? – 2013-03-11 20:29:56
@Martijn Pieters在使用unicode值的字典上进行操作时,它变得非常麻烦。 – Zero 2013-03-11 20:42:20
在Python 2中,如果您只有ASCII数据,则可以自由比较字节字符串和unicode值。以字典键的形式存储Unicode,然后用字节字符串查看值就行了。 – 2013-03-11 20:44:56