[英]sys.argv ot working in coomanline argument
I have simple python script in which I am trying to pass argument.我有简单的 python 脚本,我试图在其中传递参数。
#!/usr/bin/python
import subprocess, sys
cmd = "aws s3 ls --profile sys.argv[0]"
n = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
a,b = n.communicate()
print(a)
I tried it with below method but not working as well.我用下面的方法尝试过,但效果不佳。
cmd = "aws s3 ls --profile ' + str(sys.argv) + '"
So when I hit所以当我打
./myscript.py noc
It should get like它应该像
ln = "aws s3 ls --profile noc"
and proceed with next steps in script.并继续执行脚本中的后续步骤。
Solved it with ln = 'aws s3 ls --profile ' + str(sys.argv[1]) + ''
用ln = 'aws s3 ls --profile ' + str(sys.argv[1]) + ''
解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.