Python 16th (last lesson of the residual volume)-read, write, and append text

Source: Internet
Author: User

The teacher taught me very seriously, and the class is also vivid. This is Lesson 16th. Still lookCode:
Output parameter file('hello.txt ', 'R ')
# Output. Write ('/t you are a big/n apple ')
Read_output = output. readlines ()
Print read_output [2]
Output. Close ()

The above 'R' can be changed to 'W' and 'A' to indicate different meanings. Reading, writing, and appending are all from VB and C language. No need to say that, all understand, huh, let's continue.
Output parameter file('hello.txt ', 'R ')
# Output. Write ('/t you are a big/n apple ')
Read_output = output. Readline ()
Print read_output [2]
Output. Close ()
After the last letter S of readlines is removed, it can only display the first line of text. If you even remove line, that is: read_output = output. read, but the code below can be changed. Otherwise, you can only output one letter, and then you will not be able to laugh.

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.