我不知道这是python还是shell的问题(linux上的zsh),我有这样的一个参数:“@xyz”以“@”开头,Escape @ from python line命令
蟒蛇the_script.py first_argument @second_argument third_arg
我试图逃跑@以\或\\,或使用 “” 但该程序无法启动。如果我从@second_arguments离开@,一切都可以。
我不知道这是python还是shell的问题(linux上的zsh),我有这样的一个参数:“@xyz”以“@”开头,Escape @ from python line命令
蟒蛇the_script.py first_argument @second_argument third_arg
我试图逃跑@以\或\\,或使用 “” 但该程序无法启动。如果我从@second_arguments离开@,一切都可以。
或许“@”是zsh中的glob字符,expanding to all symbolic links in the current directory。尝试使用“@@”转义它?
尝试用echo
运行参数列表,即:
回声the_script.py first_argument @second_argument third_arg
这样的话,你可以计算出它是否扩大或原样传递到脚本。
好的,谢谢,回声测试也适用于我。我认为问题是我将@something传递给os.system – 2010-01-27 10:31:55
使用subprocess.Popen()而不是os.system。 – 2010-01-27 10:42:19
@Thomas +1总是一个很好的建议。 – 2010-01-27 11:44:51
在bash中正常工作。你确定它不仅仅是脚本本身的问题吗? – 2010-01-27 10:05:22
我有zsh 4.3.10,它工作正常。 – ghostdog74 2010-01-27 10:18:45
“不开始?”那是什么意思? – 2010-01-27 11:10:19