2010-05-15 109 views
1

我正在寫一個Python腳本在Linux上使用API​​發佈twitter,是否有可能在清晰文本中不帶撇號地傳遞符號「(」「)」等。符號在命令行參數.. python,bash

% ./twitterupdate this is me #works fine 
% ./twitterupdate this is bad :((#this leaves a error on bash. 

是唯一的選擇是將文本括入 - >「」??像..

% ./twitterupdate "this is bad :((" #this will reduce the ease of use for the script 

有什麼解決方法嗎?

回答

10

是的,引用字符串是唯一的方法。 Bash有它的語法和一些字符有特殊的意義。順便說一句,使用「」是不夠的,用撇號來代替。某些字符仍然會得到interpretted正常引號:

$ echo "lots of $$" 
lots of 15570 
$ echo 'lots of $$' 
lots of $$ 
+0

撇號..哦,會做一些好的:) – 2010-05-15 12:33:11

+1

+1爲* *極好例子。 – 2010-05-15 13:44:03