从 python 行命令中转义 @
我不知道这是 python 还是 shell(linux 上的 zsh)的问题,我有一个这样的参数:“@xyz”以“@”开头
python the_script.py first_argument @second_argumentthird_arg
I尝试用 \ 或 \\ 转义 @,或使用“”,但程序无法启动。如果我离开@second_arguments 中的@,一切都会好的。
I don't know if this is a problem with python or with the shell (zsh on linux), I've an argument like this: "@xyz" that starts with a "@"
python the_script.py first_argument @second_argument third_arg
I tried to escape @ with \ or \\, or use "" but the program doesn't start. If I leave the @ from @second_arguments everything's ok.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许“@”是 zsh 中的全局字符,扩展到当前目录中的所有符号链接。尝试用“@@”转义它?
尝试使用
echo
运行参数列表,即:echo the_script.pyfirst_argument@second_argumentthird_arg
这样,你就可以判断它是否是扩展或按原样传递给脚本。
Perhaps the "@" is a glob character in zsh, expanding to all symbolic links in the current directory. Try escaping it with "@@"?
Try running the argument list with
echo
, i.e:echo the_script.py first_argument @second_argument third_arg
That way, you can figure out if it was expanded or passed as-is to the script.