嗨,我有一个 python 脚本。 该脚本从存储帐户中提取文件并将其上传到网络驱动器。
通常,我们会收到两个或三个文件的请求。 python 脚本在 Powershell 上运行。
这是运行脚本所执行的命令行:
但是我想知道一种运行 while 循环的方法:
python .\download_files.py -f "file1" "file2" -t "459324" -e Dev -id 0
其中 f 是文件名,t 是票号,e 是环境,id 是 ID
如果我想 while 循环参数 -f,我该怎么做? 基本上,我不是将文件添加到脚本中,而是创建一个包含所有文件名的 .txt 文件,并使用 while 循环遍历每个文件。
也许
有窍门吗?比如:
文件.txt
filename1
filename2
filename3
命令行
$files = Get-Content -Path .\files.txt; python .\download_files.py -f $files -t "459324" -e Dev -id 0