"Python learning 02"-Open Read and write files

Source: Internet
Author: User

#coding =utf8f = open (' F:\xusj.txt ', ' W ') #打开xusj. txt, and write the file F.write (' Hello, ') #写入字符串f. Write (' I play python! '               ) #继续追加写入字符串f. Close #关闭字符串f = open (' F:\xusj.txt ', ' r ') #读取文件内容c = F.readline () #逐行读取print C # Test re-writes the file, discovering that the file is overwriting the previous content, rather than appending it. f = open (' F:\xusj.txt ', ' W ') f.write (' Hello twice, ') F.write (' I am coming agin. ') F.close


This article is from the "less stubborn" blog, please be sure to keep this source http://xushaojie.blog.51cto.com/6205370/1768159

"Python learning 02"-Open Read and write files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.