我可以作为一个整体运行Python文件夹或目录来执行其中的所有.py文件吗?
编辑:我正在使用Windows Powershell.
对于bash,在目录中运行所有Python文件已经回答了这个问题
你可以运行:
for f in *.py; do python "$f"; done
Run Code Online (Sandbox Code Playgroud)
如果你在Powershell,你可以使用:
Get-Childitem -Path c:\path\to\scripts -Filter *.py | % {python $_.FullName}
Run Code Online (Sandbox Code Playgroud)
EDIT:像Duncan所说,这是一个较短的解决方案Powershell:
ls C:\path\to\scripts\*.py | %{ python $_.Fullname}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
606 次 |
| 最近记录: |