擅长:python、mysql、java
<p><strong>嘿,你需要把x变量做成一个字符串格式。
您可以使用以下代码:</strong></p>
<pre><code>file = open("dicegamescores.txt","w")
x = ('on round',2,username1 ,'has',player1_score , '\n',username2,'has', player2_score)
xx = ("%s%s%s%s%s%s%s%s%s")%(x)
file.write(xx)
file.close
</code></pre>
<p><strong>对于变量中的每个字符串,应添加%s。</strong></p>