python命令行参数

洛夫什东热

我试图传递这样的命令行参数,因为实际的字符串#前后都包含一个符号

python3 test.py #fdfdf#

这是我收到的错误消息

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    print(sys.argv[1])
IndexError: list index out of range

如何传递一个包含#开头和结尾符号的字符串作为命令行参数?

更新:操作系统:Ubuntu 20.04

尼诺

您可以尝试其中一种,看看哪一种有效:

python3 test.py "#fdfdf#"python3 test.py \#fdfdf\#

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章