python - 当我在 python 中循环文件时,结果显示“无”
问题描述
我想遍历一些文件并将这些文件的内容放入一个新列表中,但是当我运行代码时,结果显示“无”。
import os
import glob
folder = os.path.join("R:", os.sep, "Files")
list = []
def notes():
for file in glob.glob(folder):
if file.endswith('.docx'):
with open(file,'r+') as f:
content = f.read()
for text in content:
new_list = list.append(text)
return new_list
print(notes())
解决方案
推荐阅读
- django - Django 反向关系(带注释和过滤)
- c++ - 如何从用户输入中打印多个浮点数,并且只有其中一些具有特定的小数位?
- python-3.x - python正则表达式匹配单词
- node.js - 如果操作请求失败,如何回滚 redux 状态和数据库
- python - 将json中的数组拆分为Python中的多个对象
- swift - 带有图像 URL 和标头的 Ximilar POST 请求
- python - 获取'关键错误:“['None'] 不在索引中
- jupyterhub - 带有 kubernetes 的 jupyterhub 是否仍处于 alpha 阶段?
- excel - 插入列和自动填充列标题的宏
- javascript - 如何在 django 模板脚本中传递静态 js 文件?