麻烦各位大佬帮忙挑下错(Python)

7183 3
雪鸦实名认证 2022-3-29 12:59:49 | 显示全部楼层 |阅读模式
import sys
try:
  file_in = open("in.txt","r")
  file_in = open("out.txt,"w+")
except IOError:                  
                 print("无法打开",file_in)
else:
                 i=1
                 for line in file_in:
                     print(line.rstrip())
                     file_out.write("line"+":"+line)
                     i = i + 1
                 file_in.close()
                 file_out.close()
                 
                 
              
                 
       :)
a2gel 2022-3-29 13:47:05 | 显示全部楼层
import sys
try:
  file_in = open("in.txt","r")
  file_in = open("out.txt,"w+")
     i=1
                 for line in file_in:
                     print(line.rstrip())
                     file_out.write("line"+":"+line)
                     i = i + 1
                 file_in.close()
                 file_out.close()
except IOError:                  
                 print("无法打开",file_in)
a2gel 2022-3-29 13:47:30 | 显示全部楼层
else前面没有if
雪鸦实名认证 2022-3-29 14:53:25 | 显示全部楼层
多谢各位大佬:)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行