在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. C++ 输入一行未知个数的整数

    C++ 输入一行未知个数的整数 代码: #include<iostream> #include<vector> using namespace std; int main() ...

  2. PHP中的国际化日历类

    在 PHP 的国际化组件中,还有一个我们并不是很常用的跟日期相关的操作类,它就是日历操作类.说是日历,其实大部分还是对日期时间的操作,一般也是主要用于日期的格式化和比较之类的.但是通常我们直接使用 d ...

  3. 超详细unittest单元测试框架总结

    unittest单元测试框架不仅可以适用于单元测试,还可以适用WEB自动化测试用例的开发与执行,该测试框架可组织执行测试用例,并且提供了丰富的断言方法,判断测试用例是否通过,最终生成测试结果.今天笔者 ...

  4. jenkins+requests+pytest+allure持续集成

    环境搭建参考:https://www.jianshu.com/p/fc39030d057f 总体流程:

  5. P5607-[Ynoi2013]无力回天NOI2017【线性基,线段树,树状数组】

    正题 题目链接:https://www.luogu.com.cn/problem/P5607 题目大意 \(n\)个数字的序列,\(m\)次操作 区间\([l,r]\)异或上一个值\(v\) 询问区间 ...

  6. Python+selenium自动化生成测试报告

    批量执行完用例后,生成的测试报告是文本形式的,不够直观,为了更好的展示测试报告,最好是生成HTML格式的. unittest里面是不能生成html格式报告的,需要导入一个第三方的模块:HTMLTest ...

  7. disruptor笔记之六:常见场景

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  8. NOIP模拟74

    前言 我就想说一句,T3 给了一个什么牛马大样例!!!!!!!!,气\(^{TM}\)死我!!!!!!! 我的 \(\mathcal{O}(n)\) 算法始终过不掉大样例我 TM ,要不然我就直接上矩 ...

  9. 题解 [SHOI2012]随机树

    题目传送门 Description \(n\le 100\) Solution Problem 1 不难看出,答案就是: \[1+\sum_{i=1}^{n-1} 2/(i+1) \] Problem ...

  10. Java中的基本类型和包装类

    Java中基本数据类型与包装类型有   基本类型     包装器类型   boolean Boolean char Character int Integer byte Byte short Shor ...