1. Modules: three methods of invocation
1. A python file written in vim * *, using Import * *, can be called directly in interactive mode
2. Call a function inside the module:
From module name in function name
3. Shorten the module name to call:
Import module formerly known as new name
2. Python-based storage directory for things:
'/usr/lib64/python2.6/site-packages ',
3. Write the file to disk:
A=file (' File name ', ' W ') ' Create new file '
A.write (' file content 1 file Content 2 ') ' Write file contents '
A.close () "Close file"
Append file contents:
A=file (' File name ', ' a ') ' Append file Contents '
A.write (' \ n file content 1 file Contents 2 ') ' Write content ' \ n ' newline
A.close () Close file
View of the file:
A=file (' filename ') ' Open file '
A.read ()"Viewing files in a read-only manner"
A.read () reads once and then reads the second time as empty, because memory frees it. If you want to save it for a long time, you have to write it into a variable and save it in memory. ' That is f=a.read () '
For line in A.readlines ():p rint line.split () [' 0 '],---"0 represents the first column"
A.readlines () reads the display as a string
**.split () Converts a string into a list
4. Delete the character set:
S.strip (RM) Remove the characters from the beginning and end of the s string in the RM delete sequence
When RM is empty, the default is to remove whitespace characters (including ' \ n ', ' \ R ', ' \ t ', ')
This article is from the Linux OPS blog, so be sure to keep this source http://9162199.blog.51cto.com/9152199/1659441
Beginners Learn Python Notes