4
for word in tweet_text:
if word in new_words:
if new_words[word] == 0:
new_words[word] = sent_count
else:
new_words[word] = (new_words[word] + sent_count)/2
一个声明,我很怀疑是不是别人块,每次执行时,第一个条件不满足(if word in new_words
)时间,这可能吗?我的身份验证有问题吗?
对我来说这似乎很好......什么是new_words和tweet_text,字典? – 2013-05-08 20:30:51
Python中的范围取决于标识,我认为如果你将空格与标签混合在一起,你的代码甚至不会运行......你确定你在说什么?你有没有调试过你的代码? – Renan 2013-05-08 20:31:09
是的,问题是,我得到KeyError异常中的其他块,但它不应该的,因为第一个条件 – 2013-05-08 20:31:35