如何使用Python从Excel中检索已保存的集合
我已经使用python 2.7
xlsxwriter
在excel
文件中保存数据。 对于检索部分,当我打印文件第一行时,它是这样的: set([u'1707242470', u'643602863', u'1677452893])
,types是unicode
。 我把这个unicode
转换成了set
然后pop
来,但是打印的时候什么也看不到。 问题是我如何检索保存的设置并正确地popup它们。 例如,第一个pop是1707242470
。 这里是我的代码:
from xlrd import open_workbook book1 = open_workbook('processed_data.xlsx') sheet1 = book1.sheet_by_name('sheet'); # I want to pop the first element of my set in my first row set third column which is 1707242470 print (set)(sheet1.cell(0, 3).value).pop();
请注意,单元格/图纸索引是从零开始的。 也不需要转换单个单元格的值来设置和使用pop()
编辑:
print sheet1.cell(0,0).value print '{}'.format(sheet1.cell(0,0).value)