命令行参数中的符号。。python,bash

命令行参数中的符号。。python,bash,python,bash,command-line-arguments,Python,Bash,Command Line Arguments,我正在Linux上使用API为twitter帖子编写一个python脚本,是否可以在明文中不加撇号地传递etc之类的符号 % ./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

我正在Linux上使用API为twitter帖子编写一个python脚本,是否可以在明文中不加撇号地传递etc之类的符号

% ./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

有什么解决方法吗?

是的,引用字符串是唯一的方法。Bash有它的语法,有些字符有特殊的含义。顺便说一句,用撇号是不够的,用撇号代替。某些字符仍将使用普通引号进行解释:

$ echo "lots of $$"
lots of 15570
$ echo 'lots of $$'
lots of $$

是的,引用字符串是唯一的方法。Bash有它的语法,有些字符有特殊的含义。顺便说一句,用撇号是不够的,用撇号代替。某些字符仍将使用普通引号进行解释:

$ echo "lots of $$"
lots of 15570
$ echo 'lots of $$'
lots of $$