【发布时间】:2017-04-25 16:21:08
【问题描述】:
import xlrd
import os
wb = xlrd.open_workbook (os.path.expanduser("~/Documents/Python/HRCQ determination TABLE.xls"))
sheet = wb.sheet_by_name('Sheet1')
sheetdict = {}
#build ductionary3
for rownum in range(sheet.nrows):
sheetdict[sheet.cell(rownum,0)] = [sheet.cell(rownum,1)]
#test print dictionary in format: Co-60 - 16 Ci
for keys,values in sheetdict.items():
print(keys,values)
这段代码的输出最终是
text:'AC225' [number:0.16]
text:'AC227' [number:0.0024]
text:'AC228' [number:14.0]
text:'AG105' [number:54.0]
text:'AG108M' [number:19.0]
text:'AG110M' [number:11.0]
等等。
我不知道 text: 和 [number: ____] 的来源。我认为它们实际上是从 excel 存储在字典中的数据的一部分,但我不知道如何删除它或 excel 正在做什么导致它。
我对 Python 非常陌生(一般是编码),因此非常感谢所有帮助。
【问题讨论】:
标签: python excel dictionary printing xlrd