我不知道這是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