繁体   English   中英

如何从另一个python脚本运行python脚本?

[英]How to run a python script from another python script?

我正在尝试从另一个运行python脚本,如下所示,某些参数使用quotes (") ,如何使用引号运行此命令?

cmd =  r"python ./clone.py -u username -rl %s -ra adar.py -d 13346612 -at "Cloning for automation" -m "Pace" -r "Cloning for automation" "%radar
proc = Popen(cmd.split(' '), stdout=PIPE, stderr=PIPE)

UPDATE#1:我尝试了以下建议,但没有一个起作用

  (i)escape the quotes
  (ii)Use multi line quotes
  (iii)Use single quotes as delimiter

更新#2:

我尝试使用shell=TRUE运行,但是python脚本挂了

您可以在字符串中使用单引号'分隔字符串,在字符串中使用双引号“分隔参数。

使用多行字符串

将cmd每边用3个单引号引起来:

即:

cmd =  ''' 
python ./clone.py -u username -rl {} -radar.py -d
13346612 -at "Cloning for automation" -m "Pace" -r "Cloning for
automation"  
'''.format(radar)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM