1
私は小さなコンタクトインポーターで作業していましたが、インポートするコンタクトの数に基づいて出力ファイルフォーマットを自動的に選択するブロックを実装しようとしています。辞書のpythonのリストから値を選択
しかし、それはエラーが発生するたびに:なぜこれが起こっている
KeyError: 'q'
は、私は私の人生のために把握することはできません、と私は提供任意のヘルプを大好きです。
私のスケーラビリティの考え方は、personDict
という辞書はpersonDict = {nameid:[name,email]}
という形式ですが、何も問題ありません。
すべてのヘルプは、
おかげ
def autoFormat():
while True:
name = input("Enter the person's name \n")
if name == "q":
break
email = input("Enter the person's email \n")
personDict[name] = [name, email]
if len(personDict) <= 10:
keyValue = personDict[name]
for keyValue in personDict:
for key, value in personDict.iteritems():
combined = "BEGIN:VCARD\nVERSION:4.0\n" + "FN:" + name + "\n" + "EMAIL:" + email + "\n" + "END:VCARD"
fileName = name + ".vcl"
people = open(fileName, 'a')
people.write(combined)
people.close()
print("Created file for " + name)
autoFormat()