擅长:python、mysql、java
<p>如果您使用的是python3,请改用print函数。你知道吗</p>
<pre><code>with open("bob.txt", "w") as myfile:
print(user1strength, file=myfile)
print(user1skill, file=myfile)
print(user2strength, file=myfile)
print(user2skill, file=myfile)
</code></pre>
<p>print函数负责为您转换成<code>str</code>,并自动为您添加<code>\n</code>。我还使用了<code>with</code>块,它将自动为您关闭文件。你知道吗</p>
<p>如果您使用的是python2.6或python2.7,则可以使用<code>from __future__ import print_function</code>访问print函数。你知道吗</p>