如何在bash命令中传递变量?

2024-05-19 08:12:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用antiword将多个.doc文件转换为.docx格式。如何编写如下命令:

for file in os.listdir(directory):
    subprocess.run("antiword file > file+'.docx'")

它显示了这个错误:

[Errno 2] No such file or directory: "antiword file > file+'.docx'": "antiword file > file+'.docx'"

除了antiword之外,没有其他方法可以正确读取对我有效的.doc文件


Tags: 文件runin命令fordocos格式

热门问题