ValueError:“攻击”不在列表中

时间:2019-03-03 22:02:35

标签: valueerror

import json
i = 1
file_name = 'PolitiFact_Fake_' + str(i) + '-Webpage.json'
with open(file_name, 'r') as fp:
    obj = json.load(fp)

    text = obj['text']

    length = len(text)
    wordlist = text.split()
    wordfreq = []
    for w in wordlist:
        wordfreq.append(wordlist.count(w))

    lengthslova = len(wordlist)
    wordfind = 'in'
    indexword = wordlist.index(wordfind)
    indexfreq = wordfreq[indexword]
    findword = [wordfreq, wordlist]

    findwordt = [[row[j] for row in findword] for j in range(lengthslova)]

    wordfind = "attacks"


    indexfreq = 0

    if indexword != ValueError:
        indexword = wordlist.index(wordfind)
        indexfreq = wordfreq[indexword]
        findword = [wordfind, indexfreq]
        indexfreq = wordfreq[indexword]
        findword = [wordfind, indexfreq]
        print('The freq of word ' + str(wordfind) + ':', indexfreq) 
    else: 
        indexfreq = 0
        findword = [wordfind, indexfreq]
        print('The freq of word ' + str(wordfind) + ':', indexfreq) 

我一直收到此错误:

  

ValueError:“攻击”不在列表中

0 个答案:

没有答案