python - argparse“找不到命令”
问题描述
使用简单密码(最多 10 个字符) argpass 有效
parser = argparse.ArgumentParser()
parser.add_argument('-p', '-password',dest='pwd',help='The password for authentication.')
args = parser.parse_args()
user = 'monitoring@domain.com'
pwd = args.pwd
conn = imaplib.IMAP4_SSL("outlook.office365.com")
conn.login(user,pwd)
但是我得到了 13 个字符的复杂密码
[1] 26160
bash: xxxxxxxx: command not found
(其中 xxxxxxxx 是最后 8 个密码字符)
script.py -password somepassword
解决方案
你正在运行类似的东西
script.py -password foo&xxxxxxxx
你的外壳解析为
script.py -password foo & xxxxxxxx
这导致在script.py -password foo
后台运行命令,然后尝试运行命令xxxxxxxx
。引用密码。
script.py -password 'foo&xxxxxxxx'
推荐阅读
- javascript - 无法从我的 index.html 中引用由 webpack 在 dist 文件夹中生成的 javascript 和 css 文件
- json - 颠簸转换为数组
- mysql - MYSQL 表导入时显示为空
- amazon-ec2 - cloud-init.yaml 中的私有 docker 注册表
- javascript - 错误未捕获的ReferenceError:分配中的左侧无效
- python - 使用带有时间序列的 Pandas DataFrame 时散点图中的着色标记
- c# - 如何在数据网格的特定行上启用特定按钮
- sql-server - 节点承诺和捕获问题
- html - 如何正确嵌套多个 ng-if?
- ansible - 动态 ansible host_vars