python - TypeError:预期的 str、字节或 os.PathLike 对象,而不是列表转换
问题描述
我不擅长python 我想在.html 中转换.log 文件.txt 我试图将值作为数组传递。但他不接受。我该如何解决这个问题TypeError: expected str, bytes or os.PathLike object, not list
?先感谢您
import txt_to_html
import os
path = 'C:\\Users\\Sandy\\PycharmProjects\\untitled1'
text_files = [f for f in os.listdir(path) if f.endswith('.log')]
txt_to_html.parse_txt(text_files)
解决方案
您可以使用下面的代码片段来实现您想要的。
import txt_to_html
import os
path = 'C:\\Users\\Sandy\\PycharmProjects\\untitled1'
text_files = [f for f in os.listdir(path) if f.endswith('.log')]
for file in text_files:
txt_to_html.parse_txt(file)
推荐阅读
- mysql - Windows 更新后 Xammp MySQL 无法启动
- google-bigquery - 根据另一个表中的开始日期和结束日期对值求和
- ios - 导航到主页后,swrevealcontroller 无法正常工作
- java - vertx.setPeriodic函数时间间隔减小的问题
- r - 在 32 位计算机上重新安装 data.table 时遇到问题
- sql - ToDate 参数未在 SSRS 报告中显示当前日期记录
- coq - 无法将变量绑定到包装的打开公式
- leaflet - 创建地图后更改 fadeAnimation 选项
- javascript - 我该如何解决这个“ajax 请求实体太大”
- node.js - 如何使用现有用户的 .id 和 mongoose 模型填充?