私は、Password
、Emailid
の3つのキーで辞書details
を作成しようとしていますが、それぞれに複数の値が含まれています。私は、Excelブックからキーの値を追加しようとしています。私は辞書のために、各特定の値にアクセスしたい複数のキー複数の値
はそうで
details{"Username":Value1,"Password":Value1,"Emailid":Value1}
言うと。
**
コードが今は読取りおよびitself.this更新コードでExcelからキーの値とそれに対応するデータを格納しようとした更新
import openpyxl
wb = openpyxl.load_workbook('user_details.xlsx')
WSheet = get_sheet_by_name('Sheet1')
# get the active working sheet 1
print('Reading rows...')
# read header values into the list
keys = [sheet.cell(0, col_index).value for col_index in xrange(sheet.ncols)]
print "keys are", keys
dict_list = []
for row_index in xrange(1, sheet.nrows):
assetData= {keys[col_index]: sheet.cell(row_index, col_index).value
for col_index in xrange(sheet.ncols)}
dict_list.append(d)
print dict_list
Trying to print the value
for k,v in assetData.items():
Print(%s "hi %s ,Records show that you have not paid dues " % (+ str(assetData[assettagtype["k"]]) +str(assetData[assettagname["k"]]))
# this line of code is just an idea ,syntactically incorrect
サンプルデータ:
username password emailid
A123 alpha [email protected]
b123 tango [email protected]
c123 charlie [email protected]
これは更新コード –