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 preprocessing
text2 = ' '.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',并注释掉了这句话
TypeError: 'in <string>' requires string as left operand, not int的更多相关文章
- TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...
- Matlab一个错误引发的血案:??? Error using ==> str2num Requires string or character array input.
Matlab总遇到一些神奇的问题,让人摸不着头脑.昨天编写程序的时候遇到一个让我十分火大的问题,也是自己的matlab基础不好吧. 先描述一下问题,再GUI界面有个listbox,Tag属性是’lis ...
- TypeError: cannot use a string pattern on a bytes-like object的解决办法
#!/usr/python3 import re import urllib.request def gethtml(url): page=urllib.request.urlopen(url) ht ...
- TypeError: cannot use a string pattern on a bytes-like object
一劳永逸解决:TypeError: cannot use a string pattern on a bytes-like object TypeError: cannot use a string ...
- 爬虫python3:TypeError: cannot use a string pattern on a bytes-like object
import re from common_p3 import download def crawl_sitemap(url): sitemap = download(url) links = re. ...
- [C#] string 与 String,大 S 与小 S 之间没有什么不可言说的秘密
string 与 String,大 S 与小 S 之间没有什么不可言说的秘密 目录 小写 string 与大写 String 声明与初始化 string string 的不可变性 正则 string ...
- java.lang.String.getBytes(String charsetName)方法实例
java.lang.String.getBytes(String charsetName) 方法编码将此String使用指定的字符集的字节序列,并将结果存储到一个新的字节数组. 声明 以下是java. ...
- Lua的string和string库总结
Lua有7种数据类型,分别是nil.boolean.number.string.table.function.userdata.这里我总结一下Lua的string类型和string库,复习一下,以便加 ...
- C#,int转成string,string转成int
转载:http://www.cnblogs.com/xshy3412/archive/2007/08/29/874362.html 1,int转成string用toString 或者Convert.t ...
随机推荐
- C#async/await心得
结论: 异步方法的方法签名要加 async,否则就算返回 Task 也是普通方法. 调用异步方法,可以加 await 或不加 await,两者方式都是马上返回,不加 await 得到的是 Task 对 ...
- Cassandra之Docker环境实践
Cassandra简介 Cassandra是一个开源分布式NoSQL数据库系统. 它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon D ...
- 自定义itemCheckView
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以 ...
- 802.11学习笔记1-WIFI参数含义
研究下wifi参数的含义 #The word of "Default" must not be removed Default CountryRegion= CountryRegi ...
- java中的异常 try catch
1.学习异常的原因? 如果没有异常处理机制,那么程序的一点小问题,都会导致[程序终止运行].实际开发中显然是不可能的,所以异常对于程序来说是非常重要的. 2.处理异常的方式: A ...
- pythonday05数据类型(三)
---恢复内容开始--- 今日内容 1.字典 2.强制转换 3.习题讲解 1.字典 帮助用户去表示一个事物的信息(事物是有多个属性). info = {"name":'刘伟达',' ...
- EFCore + MySql codeFirst 迁移 Migration出现的问题
第二次使用Migration update-database的时候出现以下错误: System.NotImplementedException: The method or operation is ...
- windows下通过idea连接hadoop和spark集群
###windows下链接hadoop集群 1.假如在linux机器上已经搭建好hadoop集群 2.在windows上把hadoop的压缩包解压到一个没有空格的目录下,比如是D盘根目录 3.配置环境 ...
- Yii 三表关联 角色表、角色权限连接表、权限表
Yii 三表关联 角色表.角色权限连接表.权限表 角色表 role----------------id 唯一序号name 角色名称---------------- 角色权限连接表 lp-------- ...
- ggplot2: how to check the color and coreponding value pairs
The way to check the color and coreponding value pairs in ggplot2 To see what colors are used to mak ...