我有以下代码从用户那里获取字符串列表作为 raw_input:
def Lookup(Dict_list):
print 'Please enter one alias per line. Leave blank when finished.'
user_alias = [alias for alias in iter (raw_input, '') ]
print user_alias
for row in Dict_list:
#print "row test"
#print row
if user_alias in row.values():
print row
for row in Dict_list:
if user_alias[0] == row['_cn6ca']:
email1 = row['_chk2m']
print email1
return email1
if user_alias[1] == row['_cn6ca']:
email2 = row['_chk2m']
print email2
return email2
if user_alias[2] == row['_cn6ca']:
email3 = row['_chk2m']
print email3
return email3
Lookup(Dict_list)
如何更改 if user_alias == row['_cn6ca']: 行,以便它查找并为每个用户输入的用户别名返回一封电子邮件?(这些键将保持不变)
我的目标是将这些查找到的电子邮件存储起来,以便稍后粘贴到 .csv 中
以下是终端中生成的内容:
请每行输入一个别名。完成后留空。PaulDu Jeanell Twanna JaneyD 夏洛特珍妮莎
['PaulDu'、'Jeanell'、'Twanna'、'JaneyD'、'Charlot'、'Janessa'] 注销
[处理完成]