原因是函数名称和系统中的某个名称相同的,替换另外的名字就行了

报错代码:

#读取docx中的文本代码示例
import docx
def docx():file=docx.Document(filename)raw_words = '' #保存所有的单词#输出每一段的内容for para in file.paragraphs:raw_words += para.text #把每段的单词添加到字符串里面raw_words = raw_words.lower()#print(raw_words)words = re.findall('[a-z]+',raw_words) #得到所有的英文单词,排除了汉语单词,各种符号return words 

修改后的代码

#读取docx中的文本代码示例
import docx
def docx_file():file=docx.Document(filename)raw_words = '' #保存所有的单词#输出每一段的内容for para in file.paragraphs:raw_words += para.text #把每段的单词添加到字符串里面raw_words = raw_words.lower()#print(raw_words)words = re.findall('[a-z]+',raw_words) #得到所有的英文单词,排除了汉语单词,各种符号return words 

替换文件名就可以了,def docx_file():

AttributeError: 'function' object has no attribute 'Document'报错解决相关推荐

  1. AttributeError: 'NoneType' object has no attribute 'grid'报错解决方案

    1问题描述: 当我们在使用tkinter时经常遇到AttributeError: 'NoneType' object has no attribute 'grid'的报错 2.原因分析: import ...

  2. AttributeError: ‘Request‘ object has no attribute ‘is_xhr‘ 报错

    在用 Flask+VUE 做前后端分离的数据可视化项目时,遇到了这个报错:AttributeError: 'Request' object has no attribute 'is_xhr' 是 We ...

  3. AttributeError: 'Request' object has no attribute 'is_xhr' 报错的解决办法

    在用 Flask+VUE 做前后端分离的数据可视化项目时,遇到了这个报错:AttributeError: 'Request' object has no attribute 'is_xhr' 是 We ...

  4. AttributeError: 'NoneType' object has no attribute 'split' 报错处理

    报错场景 social_django 组件对原生 django 的支持较好, 但是因为 在此DRF进行的验证为 JWT 方式 和 django 的验证存在区别, 因此需要进行更改自行支持 JWT 方式 ...

  5. 【Django】‘function‘ object has no attribute ‘subjects‘报错的解决

    项目场景 创建了一个新文件夹 myapp ,用于保存新功能模块下实现功能的代码文件 views.py . 问题描述 运行项目时,报错 'function' object has no attribut ...

  6. AttributeError: ‘PosixPath‘ object has no attribute ‘rstrip‘ 报错问题记录

    环境 python3.6.5 django 3.1.5 问题定位及解决 最近准备开发一个在线教育的网站,各个环境都搭好了,并且测试demo 也能跑的好好的,为了以后 调试接口方便,所以我打算把swag ...

  7. 解决AttributeError: 'str' object has no attribute 'decode'报错问题

    顺着报错文件点进去,找到query = query.decode(errors='replace') 将decode修改为encode即可

  8. AttributeError: module ‘tushare‘ has no attribute ‘get_k_data‘报错解决方法

    出现标题所示错误时,出错原因是你的python文件命名成了tushare.py,python解释器解析代码的时候从你的文件里找函数未找到而报错.

  9. 'Request' object has no attribute 'META'报错解决

    代码如下: class OrderShipping(LoginRequiredMixin, View):def get(self, request):print("request=" ...

最新文章

  1. 【Android应用开发】EasyDialog 源码解析
  2. C语言内存泄漏案例及解决办法
  3. us域名在哪里注册_独立站如何选择一个合适的域名?
  4. 《前端JavaScript重点》学习笔记 1-5
  5. (47)FPGA指数运算符(V代码实现)
  6. 终于圆了天文梦!马化腾称腾讯将发布探星计划 还提到了《王者荣耀》
  7. 删除oracle补丁包,最新Oracle关键补丁:更新包括248个修复
  8. android datepicker 监听,Android编程之DatePicker和TimePicke简单时间监听用法分析
  9. s7 edge android 8,盖乐世S7/S7edge 正式开启Android 8.0系统内测活动
  10. (一)Redfish简介
  11. 送给大家一个很好的Web前端开发工具
  12. Ubuntu18.04运行QQ音乐
  13. 电商后台设计详细讲解
  14. java首行缩进两个字符,CSS 首行缩进两个文字
  15. linux学习记录(二)
  16. 我的申请已经通过审核,你想成为阿里云 MVP 吗?
  17. 不能错过的徒步欢乐:从秦皇岛到北戴河
  18. 怎么画动漫人物的五官:耳鼻眼嘴
  19. 12款好用的Visual Studio插件,最后一款良心推荐
  20. Jasper(2)——简单使用导出PDF报表

热门文章

  1. 基于依赖统计的方法——TPDA
  2. ubuntu的磁盘扩容
  3. 使用InternalsVisibleToAttribute给assembly添加“友元assembly”特性遭遇强签名
  4. Windows编译libcaffe时报cudnn.hpp(114): too few arguments in function call错误
  5. vmware中nat模式中使用静态ip后无法上网的问题
  6. Powershell调用静态方法
  7. UIImagePickerController
  8. windows server 2012安装
  9. @清晰掉 C++ 中的 enum 结构在内存中是怎么存储的?
  10. Android多媒体应用开发-控制摄像头拍照