终端循环适用于mac,但不适用于pc python

终端循环适用于mac,但不适用于pc python,python,macos,shell,pc,Python,Macos,Shell,Pc,我有一个在mac上使用的终端循环命令: for i in {1..30}; do python Rev1stRT.py A${i}F.txt FirstRevRtA${i}.txt; done 这适用于一组名为A1F.txtA2F.txtA3F.txt等的文件 我已为该学生发送命令(她使用pc),但她收到以下错误: Missing opening '(' after keyword 'for'. At line:1 char:5 for <<<< i in {1..30

我有一个在mac上使用的终端循环命令:

for i in {1..30}; do python Rev1stRT.py A${i}F.txt FirstRevRtA${i}.txt; done
这适用于一组名为
A1F.txt
A2F.txt
A3F.txt
等的文件 我已为该学生发送命令(她使用pc),但她收到以下错误:

Missing opening '(' after keyword 'for'.
At line:1 char:5
for <<<< i in {1..30}; do python Rev1stRT.py A${i}F.txt FirstRevRtA${i}.txt; done
CategoryInfo    : ParserError: (OpenParenToken:TokenId) [], ParentContainsErrorRecordException
FullyQualifiedErrorId: MissingOpenParenthesisAfterKeyword  

Windows Powershell中的循环具有不同于
bash
的语法,后者是Mac上终端的默认shell

假设安装了Python并将其添加到
Path
环境变量中,类似这样的操作将起作用:

for ($i=1; $i -le 30; $i++) {
    python Rev1stRT.py "A$iF.txt" "FirstRevRtA$i.txt";
}

参考资料:

您的学生是否可能使用语法与您不同的shell?我也试图用谷歌搜索shell和terminal之间可能存在的差异,但没有运气:如果您搜索,例如,
FullyQualifiedErrorId
。。。你的结果有规律吗?他们是否总是提到Windows的PowerShell?您是否希望Mac上正常的东西能够在MS Windows系统上工作(不做任何修改)?实际上,小shell脚本部分也可以轻松集成到Python程序中,这应该可以通过提高性能来解决问题,因为每次迭代都不会启动新的Python实例。@guidot我同意,在程序本身中使用
os
模块将更容易、更干净!是的,python安装在那台电脑上,因为我的学生能够在运行它们的所有30个数据文件中逐个运行脚本,但循环不起作用。
for ($i=1; $i -le 30; $i++) {
    python Rev1stRT.py "A$iF.txt" "FirstRevRtA$i.txt";
}