Python Notes (vii)

Source: Internet
Author: User

#-*-coding:utf-8-*-#Python file I/O    #Print to screen#Print 1234567    #reading screen input#input_str=raw_input ("please:") # Enter 2*3 at the same time#print "Your input is:", Input_str # output 2*3#input_str=input ("please:") # Enter 2*3 at the same time#print "Your input is:", Input_str # output 6,input and raw_input basically similar, but input can accept the Python expression, and the results returned    #Open Close FileFile=open ("Log.txt","w+") File.write ("Hello")PrintFile.readline (10)    #File LocationFile.tell ()#gets the current unknown within the file. File.seek (0,0)#used to change the position of the current file, the first parameter represents the offset, that is, how much to move, the second parameter represents a reference, that is, where to start moving, 0 means to move from the beginning of the file, 1 to move from the current position, and if set to 2 to start moving from the end of the fileFile.close ()#Close () method closing a file is a good habit    #renaming and deleting filesImportOs#Python's OS module provides a way to manipulate filesOs.rename ("Log.txt","New_log.txt") Os.remove ("New_log.txt")ifOs.path.exists ("Test"): Os.rmdir ("Test") Os.mkdir ("Test")#Os.chdir ("Newdir") no longer demonstrates herePrintOS.GETCWD ()#Show Current working directory

Python Notes (vii)

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.