Stupid Methodology python--Exercise 16

Source: Internet
Author: User

#-*-Coding:utf-8-*-
From sys import ARGV

script, filename = argv

Print "We ' re going to erase%r"% filename
Print "If you don t want this, hit Ctrl-c (^c)."
Print "If You do want this, hit RETURN."

Raw_input ("?")

Print "Opening the file ..."
target = open (filename, "w")
# Here's W should be the focus, there are many uses such as r A, brain cells are not enough
Print "truncating the file. goodbye! "
Target.truncate ()
# Here for the moment don't understand, online said this should have truncated function, but delete this line of code, run without any impact
Print "Now I ' m going-ask you for three lines."

line1 = Raw_input ("Line 1:")
Line2 = Raw_input ("Line 2:")
Line3 = Raw_input ("Line 3:")

Print "I ' m going to write these to the file."

Target.write (line1)
Target.write ("\ n")
Target.write (line2)
Target.write ("\ n")
Target.write (LINE3)
Target.write ("\ n")

Print "And finally, we close it."
Target.close ()
# There are several functions in the exercise, raw_input (), open (), truncate (), write (), close ()
# Open the document with the opening command first,

Stupid Methodology python--Exercise 16

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.