[英]Ignore special meaning of characters in command line and handle them as strings
So I need to write a program in python3 that will read in 2 command line arguments userName and passWord.所以我需要在 python3 中编写一个程序,它将读取 2 个命令行参数 userName 和 passWord。 What I am struggling with is the fact that if the user enters a character with special meaning in bash (eg ', \\n, \\b etc.) my bash executes it.
我正在努力解决的是,如果用户在 bash 中输入一个具有特殊含义的字符(例如 '、\\n、\\b 等),我的 bash 会执行它。 What I need is to somehow ignore the special meaning of those characters and simply read them in as strings.
我需要以某种方式忽略这些字符的特殊含义,并简单地将它们作为字符串读入。 I have no control over what the input is gonna be and I cannot tell the user to escape them.
我无法控制输入将是什么,我无法告诉用户逃避它们。 I am simply accepting whatever the user throws at me.
我只是接受用户扔给我的任何东西。
You should be able to add each argument in double quotes "argument"您应该能够在双引号“参数”中添加每个参数
For example:例如:
python myScript.py "peter" "my/weird%^#password"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.