Python file operations
One, read operation, the difference of 3 kinds of reading methods
#!/usr/bin/env python#-*-Coding:utf-8-*-#-author-lianinfo_file = open ("Here_we_are", encoding= "Utf-8") # The default read mode print (info_file) #不加参数 to print #<_io directly. Textiowrapper name= ' here_we_are ' mode= ' r ' encoding= ' Utf-8 ' > #print (Info_file.read ()) #read参数, read all contents of File # The more I'm at a loss, the more I'm going to backfire # in the staggered space # The soul is accelerating down #here we is, here we is, here we Are#print (Info_file.readline ()) #readline, Read only one line in an article # The more I can't get it print (Info_file.readlines ()) #readlines, the article content in line with newline characters, and generate a list format, the data volume is not recommended to use #[' I'm more confused ', ' The more it backfired \ ', ' in the staggered space \ \ ', ' The soul is accelerating down \ ', ' Here we is, here we're, here we are\n ']
Python development "Chapter three": Python file operations