擅长:python、mysql、java
<p>您应该关闭文件以查看更改。你知道吗</p>
<pre><code>f = open('%s.txt' %(ogrenci_listesi[x]) ,'a')
if bilissel_olay_1 == 1:
f.write(bilissel_olay[3])
elif bilissel_olay_1 == 2:
f.write(bilissel_olay[2])
elif bilissel_olay_1 == 3:
f.write(bilissel_olay[1])
elif bilissel_olay_1 == 4:
f.write(bilissel_olay[0])
x=x+1
f.close() #close the file when you are done writing.
</code></pre>
<p>或者在处理文件时最好使用<a href="https://docs.python.org/2/tutorial/inputoutput.html#methods-of-file-objects" rel="nofollow">with()</a>。你知道吗</p>
<pre><code>with open('%s.txt' %(ogrenci_listesi[x]) ,'a') as f:
...
#do your stuff.
</code></pre>
<p>如果使用<code>with</code>,则无需手动<code>close</code>文件。你知道吗</p>
<p><strong>编辑评论是实际问题:</strong><br/>
因为<code>input</code>返回<code>string</code>,并且<code>1</code>是整数,所以它总是<code>False</code>。所以要么把<code>1</code>改成<code>"1"</code>要么<code>bilissel_olay_1 = int(input())</code></p>