#-*-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)