我有一個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