首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用python运行windows命令

如何使用python运行windows命令
EN

Stack Overflow用户
提问于 2020-05-12 12:15:57
回答 1查看 48关注 0票数 0

代码如下:

代码语言:javascript
运行
复制
import os
from pathlib import Path

thisDir = Path("C:/Users/91883/Downloads/Telegram Desktop")

for r, d, f in os.walk(thisDir):
    for file in f:
        if file.endswith('mkv'):
            arg =  os.path.join(Path("C:/Program Files/MKVToolNix/mkvpropedit.exe"), Path(f' {thisDir}/{file} -e info -s title=""'))
            os.popen(arg)

基本上,我想运行这个cmd:

"C:\Program Files\MKVToolNix\mkvpropedit.exe" "C:\Users\91883\Downloads\Telegram Desktop\file.mkv" -e info -s title=""

EN

回答 1

Stack Overflow用户

发布于 2020-05-12 12:21:53

为了使用Python运行命令,可以使用这个os.system()函数。

代码语言:javascript
运行
复制
os.system("Enter your command here.")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61743729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档