用python的open()函数打开文件时,

1、文件写绝对路径报IOError: [Errno 2] No such file or directory。文件改为相对路径(只写文件名)解决该问题

2、文件是docx类型,如下代码执行时报TypeError: file() takes at most 3 arguments (4 given)path = r'file2.docx#ignore 忽略错误

path = r'file2.docx'
#ignore 忽略错误
f = open(path, 'r',encoding = 'utf-8',errors = 'ignore'

引入io模块,解决该问题,代码如下:
import io
path = r'file2.docx'
#ignore 忽略错误
f = io.open(path, 'r',encoding = 'utf-8',errors = 'ignore')

最新文章

  1. asp.net[web.config] httphandlers 与实现自由定义访问地址
  2. js去掉html标签和去掉字符串文本的所有的空格
  3. 射击比赛 (POJ 1719) 题解
  4. outlook配置
  5. C# DataGridView的初始化
  6. Delphi中DLL的其他应用
  7. Excel中将时间格式转化成时间戳格式
  8. PLSQL连接Oracle数据库,使用instantclient_10_2客户端
  9. struts2 DMI问题
  10. PHP 11:函数
  11. Docker 搭建 etcd 集群及管理
  12. 总结两种动态代理jdk代理和cglib代理
  13. 第二篇:数据可视化 - 基本API
  14. [转] 分代垃圾回收的 新旧代引用问题(原标题:Back To Basics: Generational Garbage Collection)
  15. node webpack4.6简单配置
  16. 【BZOJ2159】Crash的文明世界
  17. sql 存储过程命名规范
  18. mysql自动创建分区
  19. Redis 缓存服务配置与使用
  20. hightcharts 如何修改legend图例的样式

热门文章

  1. 搜索引擎学习(六)Query的子类查询
  2. Oracle学习(五)DBLINK
  3. google chrome安装非官方市场插件方法
  4. websocket+sockjs+stompjs详解及实例
  5. mysql-1-select
  6. 软件定义网络实验记录①--Mininet 源码安装和可视化拓扑工具
  7. VS2013 C++ 生成与调用DLL(动态链接库) 需要验证
  8. Eclipse 重命名工程、包、类
  9. 实现Excel文件的上传和解析
  10. Avoid mutating a prop directly since the value will be overwritten whenever the parent component re