Tip: Use Help when the module method is not used
>>> Import re
>>>help (Re.search)
To view all the methods of a module:
>>>import RE
>>>dir (RE)
1. SYS module
SYS.ARGV contains a list of command-line arguments, and the name of the script is always sys.argv the first parameter of the list, which is sys.argv[0]
2. OS Module
The Python module contains common operating system features.
Run the shell command in Python
1, os.system (' command ');
2, Result=os.popen (command). Read ()
Command= "grep" + string1+ "SU-B1.FA | Wc-l "
return result
os.path.join ('dir ', 'file ') #拼接PS:os.path.join () is not the same as the String.Join () method
Os.listdir (' Xxoo ') returns all filenames and directory names for the specified directory;
3. Re module
The Re.match method determines whether the match is true and returns a match object if the match succeeds, otherwise None is returned.
The Re.search method finds a pattern match within the string until the first match is found and then returns none if the string does not match.
The difference between Re.match and Re.search: Re.match matches only the beginning of the string, if the string starts not conforming to the regular expression, the match fails, the function returns none, and the Re.search matches the entire string until a match is found.
Re.sub () #实现正则的替换, Re.sub replaces all occurrences, not just the first one.
>>>import RE
>>>re.sub ('[ABC] ' , 'o ' , ' caps ')
' Oops '
About Re.sub In addition to the regular, you have seen another use, such as:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/59/93/wKioL1TYianRnl25AAKnVx0wZ3Q073.jpg "title=" Ee931594-a51a-4e9c-9b8c-c4a2a3f8dc83.png "alt=" Wkiol1tyianrnl25aaknvx0wz3q073.jpg "/>
ARGV[2] in place of agrv[1] in argv[3].
4. Time Module
Time.mktime (t): Converts a struct_time to a timestamp.
For example:
>>>time.mktime (Time.localtime ())
1419480062.0
-
-
UTC (coordinated Universal time, world co-ordination) that is Greenwich Astronomy, world standard Time. In China for Utc+8. DST (daylight saving time) is daylight saving time.
-
timestamp (timestamp): Typically, timestamps represent January 1, 1970 00:00:00 starts the offset by seconds. We run "type (Time.time ())" and return the float type. The function that returns the Timestamp method mainly has time (), clock () and so on.
-
5. String module
The Join method requires two parameters, one is list, the other is a delimiter, and a delimiter joins all elements (strings) inside the join into a new string
>>>a= ' abc '
>>>string.join (A, ', ') <=> ', '. Join (a)
' A,b,c '
Split method: Splitting a string
Python module knowledge (continuous update ...)