我正在 Linux 上使用 API 为 twitter 帖子编写 python 脚本,是否可以在没有撇号的情况下以明文形式传递诸如“(”“)”等符号....
% ./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 $$
