<p>我试图用带有%的用户定义的字符串打开一个带有exe的文件,这对我来说是不起作用的。我试过了操作系统以及os.popen公司. 我一直得到这个<br/>
TypeError:不支持%的操作数类型:“file”和“str”</p>
<p>我该怎么做才能让它成功呢?在</p>
<pre class="lang-py prettyprint-override"><code>def showhelp():
defaulteditor = "notepad.exe"
print "[*] Which text viewer do you want to use? [default: notepad]"
which = raw_input("\n\n\ntype n for notepad, or specify program.exe > ")
if which != "n":
os.popen('notepad ./help.txt')
else:
os.popen('%r')%(which)
</code></pre>