私はワードカウントプログラムで作業しています。このコードの値エラー:アンパックするには1つ以上の値が必要です
#!/usr/bin/env python
import sys
# maps words to their counts
word2count = {}
# input comes from STDIN
for line in sys.stdin:
line = line.strip()
word, count = line.split('\t', 1)
try:
count = int(count)
except ValueError:
continue
try:
word2count[word] = word2count[word]+count
except:
word2count[word] = count
for word in word2count.keys():
print '%s\t%s'% (word, word2count[word])
エラー:
word, count = line.split('\t', 1)
ValueError : need more than 1 value to unpack
「行」にタブがないことを意味します。 – jonrsharpe
私もタブでチェックしましたが、同じエラー – Madhu
どういう意味ですか?もともと何を試していたのですか? –