Shi*_*pak 1 python bash command-line-arguments
我正在使用API在Linux上编写一个python脚本的twitter帖子,是否可以在没有撇号的明文中传递像"("")"等符号....
% ./twitterupdate this is me #works fine
% ./twitterupdate this is bad :(( #this leaves a error on bash.
Run Code Online (Sandbox Code Playgroud)
唯一的选择是将文本括在 - >""?? 喜欢..
% ./twitterupdate "this is bad :((" #this will reduce the ease of use for the script
Run Code Online (Sandbox Code Playgroud)
有没有解决方法?
Luk*_*ský 10
是的,引用字符串是唯一的方法.Bash有它的语法,有些字符有特殊含义.顺便说一句,使用""是不够的,改用撇号.某些字符仍将使用正常引号进行解释:
$ echo "lots of $$"
lots of 15570
$ echo 'lots of $$'
lots of $$
Run Code Online (Sandbox Code Playgroud)