2010-05-15 116 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