我在编译时遇到错误

时间:2019-03-26 17:18:53

标签: python python-3.x typeerror

我正在编译时遇到错误

if(window.innerWidth >= 1024){
   wheel.sliceTransformFunction = sliceTransform().ScaleTitleTransform;
} 

我的输出是:

import pickle as pickle`
from nltk.stem.wordnet import WordNetLemmatizer
import nltk
import sys

def tokenize(text):
lmtzr = WordNetLemmatizer()
tokens = nltk.word_tokenize(text)
l = []
for t in tokens:
    try:
        t = float(t)
        l.append("<NUM>")
    except ValueError:
        l.append(lmtzr.lemmatize(t))
return l


def predict(headline):
    try:
        f = open('trained_model')
        clf = pickle.load(f)
        f = open('vectorizer')
        vectorizer = pickle.load(f)
        return clf.predict_proba(vectorizer.transform(headline))[0][1]
    except IOError:
    print("Model not present, run train.py first")


if __name__ == "__main__":
    print ("headline is ") + str(int(predict([sys.argv[1]])*100)) + ("% likely to be clickbait")

1 个答案:

答案 0 :(得分:1)

您在第一个字符串之后关闭了:P1_HIDDEN='YES' AND P1_DD1 IS NOT NULL引号的括号,因此它print是该字符串,然后使用print返回的None来尝试与您的其余输出连接。想必您想要:

print

除了删除第一个字符串后的封闭括号和最后一个字符串前的开放括号之外,其他均相同。