簡體   English   中英

在 subprocess.run python 中傳遞變量值

[英]passing variable value in subprocess.run python

如何在子進程運行中調用此變量sd_namesp 當我嘗試使用以下方法執行此操作時,我得到無效的語法我也嘗試了f"{sd_namesp}"也不起作用

for seccontent in sec_ver_data:
    sd_namesp = seccontent.get("name") + seccontent.get("ition") + str(seccontent.get("version")
    largs = ['java','-jar','cli.jar','n','-cf', config_path, '-r', seccontent.get("reg"), '-n', seccontent.get("name"), '-i', seccontent.get("sid"), '-f', sd_namesp]
    lresp = subprocess.run(largs, text=True, capture_output=True, check=True)
    print(lresp.stdout)
print("end")

您可能會遇到語法錯誤,因為您似乎忘記在此處關閉括號:

sd_namesp = seccontent.get("name") + seccontent.get("ition") + str(seccontent.get("version"))

注意末尾多余的括號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM