美文网首页
Python 文件操作

Python 文件操作

作者: CaptainRoy | 来源:发表于2018-11-12 19:05 被阅读1次
    string = '''Programming is fun
    when the work is done
    if you wanna make your work also fun:
      use Python
    '''
    
    f = open('string.text','w')
    f.write(string)
    f.close()
    
    f = open('string.text','r')
    while True:
        line = f.readline()
        if len(line) == 0:
            break
        print(line,end='')
    
    f.close()
    

    相关文章

      网友评论

          本文标题:Python 文件操作

          本文链接:https://www.haomeiwen.com/subject/dxncfqtx.html