TypeError: 'in string' requires string as left operand, not int

编程入门 行业动态 更新时间:2024-10-28 03:23:06

TypeError: 'in string' <a href=https://www.elefans.com/category/jswz/34/1771284.html style=requires string as left operand, not int"/>

TypeError: 'in string' requires string as left operand, not int

  • 报错
Traceback (most recent call last):File "D:/PyCharm 5.0.3/WorkSpace/2.NLP/9.DL在NLP中的应用/4. VectorizerVisualization.py", line 45, in <module>lines.append(preprocessing(line))File "D:/PyCharm 5.0.3/WorkSpace/2.NLP/9.DL在NLP中的应用/4. VectorizerVisualization.py", line 18, in preprocessingtext2 = ' '.join(' '.join([' ' if ch in string.punctuation else ch for ch in text]).split())File "D:/PyCharm 5.0.3/WorkSpace/2.NLP/9.DL在NLP中的应用/4. VectorizerVisualization.py", line 18, in <listcomp>text2 = ' '.join(' '.join([' ' if ch in string.punctuation else ch for ch in text]).split())
TypeError: 'in <string>' requires string as left operand, not int
  • 原因
    需要字符串作为左操作数,而不是int
  • 解决
    line = line.strip().decode("ascii", "ignore").encode("utf-8")
    这句话不知道为什么有问题,所以将打开文件的'rb'改成'r',并注释掉了这句话

转载于:.html

更多推荐

TypeError: 'in string' requires string as left operand, not int

本文发布于:2024-03-14 21:01:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1737320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:requires   string   TypeError   int   operand

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!