一、读取文件,打印第三行时后面加入“徐亚平”

 程序如下:

count=0
with open("test",mode="r",encoding="utf8") as f:
    for line in f:
 
        if count==2:
            line="".join([line.strip(),"徐亚平"])

        print(line.strip())
        count+=1

  

 1 Somehow, it seems the love I knew was always the most destructive kind
 2 不知为何,我经历的爱情总是最具毁灭性的的那种
 3 Yesterday when I was young
 4 昨日当我年少轻狂
 5 The taste of life was sweet
 6 生命的滋味是甜的
 7 As rain upon my tongue
 8 就如舌尖上的雨露
 9 I teased at life as if it were a foolish game
10 我戏弄生命 视其为愚蠢的游戏
test

相关文章:

  • 2021-10-02
  • 2021-06-26
  • 2021-07-21
  • 2022-02-09
猜你喜欢
  • 2021-06-06
  • 2021-08-09
  • 2022-02-04
  • 2021-06-17
  • 2022-12-23
  • 2021-08-08
  • 2021-07-29
相关资源
相似解决方案