私はPythonを使い、辞書を理解しようとしています。私はこのエラーに関連する前に質問されていることを知っていますが、私の問題を理解する助けにはなりません。辞書を理解しようとしています
私は次のコード
mailSender = dict()
count = 0
name = input("Enter file:")
handle = open(name)
for line in handle:
line = line.rstrip()
if not line.startswith("From "):
continue
count = count + 1
senderNames = line.split()
# print(splitLines[1])
print(senderNames[1])
if senderNames not in mailSender:
mailSender[senderNames] = 1
else:
mailSender[senderNames] = mailSender[senderNames] + 1
# print(mailSender)
を持っている私は、NNDが、その後、ほとんどの電子メールの送信者見つけ、テキストファイルのための電子メールアドレスを選び出すしようとしています。私は私が間違っているつもり場所を確認するために経験を持っていない
if senderNames not in mailSender: TypeError: unhashable type: 'list'
、と私は誰かがそれにいくつかの光を当てることを願って:
私は、次のエラーを得続けます。
'senderNames'はリストです。リストは変更可能であるためハッシュ可能ではなく、dictキーはハッシュ可能である必要があります。 –