在python2.7中这样调用代码

open('file/name.txt','r',encoding= 'utf-8').read()

会出现

TypeError: 'encoding' is an invalid keyword argument for this function

这样的错误

需要将代码修改为

import io
io.open('file/name.txt','r',encoding= 'utf-8').read()

TypeError: 'encoding' is an invalid keyword argument for this function 解决Python 2.7的更多相关文章

  1. TypeError: 'encoding' is an invalid keyword argument for this function

    python 2.7 问题 data_file = open("F:\\MyPro\\data.yaml", "r", encoding='utf-8') 运行 ...

  2. python 2.7版本解决TypeError: 'encoding' is an invalid keyword argument for this function

    今天在用yaml处理数据时,由于yaml.load可接收一个byte字符串,unicode字符串,打开的二进制文件或文本文件对象,但字节字符串和文件必须是utf-8,utf-16-be或utf-16- ...

  3. python TypeError: ‘encoding’ is an invalid keyword argument for this function

    shell调用python脚本出现了这个问题,查询原因得知,python脚本是python3.6写的,我们服务器上默认的python是python2.7.3,所以会出现编码问题. 解决思路: 1.安装 ...

  4. TypeError: 'newline' is an invalid keyword argument for this function 错误解决

    出错代码: outputFile = open('output1.csv', 'w', newline='') # error line outputWriter = csv.writer(outpu ...

  5. TypeError: parse() got an unexpected keyword argument 'transport_encoding'

    错误: TypeError: parse() got an unexpected keyword argument 'transport_encoding'You are using pip vers ...

  6. TypeError: __init__() got an unexpected keyword argument 't_command'

    python  .\manage.py migrate 报错如下 λ python .\manage.py migrateTraceback (most recent call last): File ...

  7. TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations'

    错误: TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations' 参照https://blog.c ...

  8. TypeError: to_categorical() got an unexpected keyword argument 'nb_classes'

    在学习莫烦教程中keras教程时,报错:TypeError: to_categorical() got an unexpected keyword argument 'nb_classes',代码如下 ...

  9. TypeError: pivot_table() got an unexpected keyword argument 'rows'

    利用Python进行数据分析>第二章,处理MovieLens 1M数据集,有句代码总是报错: mean_rating = data.pivot_table('rating', rows='tit ...

随机推荐

  1. axios与vue-resource

    在Vue项目中前后端交互时,早期Vue使用Vue-resource实现异步请求.从Vue2.0之后就不再对vue-resource进行更新,Vue官方推荐使用axios. vue-resource V ...

  2. mysql事务干货详解

    说明: mysql是现在行业中流行的关系型数据库,它的核心是存储引擎.mysql的存储引擎有很多种我们可以通过命令查看如下 SHOW ENGINES 不同版本得到的数据不一样,我们今天说的事务是在 M ...

  3. Java基础系列(26)- 打印三角形

    package struct; public class TestDemo { public static void main(String[] args) { for (int i = 1; i & ...

  4. Nginx系列(10)- Nginx配置文件详解

    nginx文件结构 ... #全局块 events { #events块 ... } http #http块 { ... #http全局块 server #server块 { ... #server全 ...

  5. Docker系列(12)- 部署Tomcat

    #官方的使用:我们之前的启动都是后台,停止容器后,容器还是可以看到#docker run -it --rm,一般用来测试,用完就会删除容器,镜像还在[root@localhost ~]# docker ...

  6. [手机编程]Aid Learning--换源+数据库安装

    换源+MYSQL安装 Aid Learning下载安装 http://www.aidlearning.net/ 切换源 打开Terminal复制回车即可 cd /etc/apt/&& ...

  7. ubuntu提示:无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)

    root@uni-virtual-machine:/home/uni# apt install apt-transport-https ca-certificates curl software-pr ...

  8. 第三方api接口

    做为一个软件测试工程师,你要学习接口测试,需要练习,那么就要有调用的api,可以参考以下的文章. 国内7款API供应平台功能对比及详细介绍 https://blog.csdn.net/ishxiao/ ...

  9. LR进行内外网附件上传并发——实践心得

    刚开始接触LR的时候,做了一次内外网附件上传的并发测试,比较简单,但当时理解有些欠缺.以下为当时的实践心得: 1.分内外网测试的意义: 内网测试主要看负载压力情况等,外网测试主要考虑网络带宽.网络延时 ...

  10. 虚拟机安装配置centos7

    安装 https://blog.csdn.net/babyxue/article/details/80970526 主机环境预设 更换国内yum源 epel源 https://www.cnblogs. ...