我差不多有这行代码 -
Popen(["C:\Users\Johannes\Documents\A Customized JonDoFox Portable Profiles - Beta 2\JonDoFoxPortable1\JonDoFoxPortable.exe", "https://www.amazon.com/gp/sign-in.html"], )
但是我需要在JonDoFoxPortable(VariableHere)中插入一个变量,所以它看起来像那样 -
Popen(["C:\Users\Johannes\Documents\A Customized JonDoFox Portable Profiles - Beta 2\JonDoFoxPortable(VariableHere)\JonDoFoxPortable.exe", "https://www.amazon.com/gp/sign-in.html"], )
仍然是初学者,但如果有人有任何想法,我将感激不尽:)
答案 0 :(得分:1)
您可以使用format
功能。
>>> txt = "MyText{}"
>>> txt.format(2)
'MyText2'
答案 1 :(得分:1)
有多种方式:
Popen(["C:\Users\Johannes\Documents\A Customized JonDoFox Portable Profiles - Beta 2\JonDoFoxPortable" + variable + "\JonDoFoxPortable.exe", "https://www.amazon.com/gp/sign-in.html"], )
Popen(["C:\Users\Johannes\Documents\A Customized JonDoFox Portable Profiles - Beta 2\JonDoFoxPortable%a\JonDoFoxPortable.exe"%variable, "https://www.amazon.com/gp/sign-in.html"], )
或者Sukrit Kalra发布的内容