1.os Module
1.1 OS.GETCWD ()
# get current directory a=os.getcwd ()print(a)
1.2 Os.chdir ()
# Change Script current directory os.chdir ('path')
1.3 Os.makedirs ()
Os.makedirs ('dirname1/diename2')
1.4 Os.removedirs ()
Delete the folder, you can delete the current file under the sub-folder, not empty, the empty is all deleted
1.5 Os.makedir ()
Create a single folder
1.6 Os.rmdir ()
Delete a single folder
1.7os.stat ()
Get information about a file, including creation time, modification time, etc.
2.sys Module
2.1 Sys.exit ()
Exit the Py file run
2.2 SYS.ARGV
This command, is that many programs need to enter data in the process of running the program, this is to enter the data in advance, eliminating the waiting time
2.3 Sys.stdout.write (' #)
Want to print something on the screen
Import Sys,time for in range: sys.stdout.write ('# #') time.sleep ( 1) Sys.stdout.flush ()# # # # # # # # # # # # # # # # # # Two # of the code that runs # # every second to the screen #
3.json Module
Why use a JSON module? Because JSON is cross-platform and is used extensively in every language, it can improve compatibility
3.1 Json.dumps ()
Import jsondic={'Alex':'+ '# Note the JSON-type string , all in double quotes, at which point the single quote a=json.dumps (DIC)print(a) {"Alex " " - "} # automatically outputs into double quotes, and is compatible with each platform
There is a shortcut, Json.dump (' Sjah ', f)
The former is the data that needs to be written, and the latter is the file to be written, which is relatively fast
3.2 Json.loads ()
Take the JSON type string out, note that it must be double quotes, this also has a relatively fast method
Json.load () # # #
With open ('data.json'R') as f: = Json.load (f)
4.pickle Module
The pickle module is similar to the JSON module
5.shelve Module
As long as an open method, the returned object is similar to a dictionary, readable writable, key is a string, and the value is all types supported by Python
How to use
Import= Shelve.open ('shelve.db', flag='C', protocol=2, writeback=False) d['Alex']={' who are you, I like you so much, Now 2018-6-26 night 11 o'clock, I miss you '}
Shelve open (' Aaa.txt ', ' R ')
2018-06-26-python full Stack Development day22-part1-os,json,sys,pickle,shelve module Introduction