Professional Documents
Culture Documents
Python Training Course IX: System
Python Training Course IX: System
System
System
Files
Directories
Programs and Processes
Calendars and Clocks
2
Files
3
Check Existence with exists(); Check Type with isfile()
絕對目錄
( . ) is current directory
( .. ) stands is parent directory
4
Copy with copy()
5
Link with link() or symlink()
hard link
6
Change Permissions with chmod()
7
Change Ownership with chown()
8
Get a Pathname with abspath()
9
Directories
10
Create with mkdir()
11
List Contents with listdir()
12
Change Current Directory with chdir()
13
List Matching Files with glob()
14
練習題
Book P.259
Things to Do 10.1~10.5
15
Programs and Processes
16
getpid(), getcwd(), getuid(), getgid()
get my user ID
get my group ID
17
Create a Process with subprocess
僅在 shell 另執行程式,並取得輸
出
( 標準輸出或錯誤輸出 )
也可以加入引數
也可以加入
pipe 導到另一
支程式
takes a list of the command and arguments
By default it only returns standard output
as type bytes rather than a string and does
not use the shell
18
Create a Process with subprocess
19
Calendars and Clocks
20
calendar.isleap()
是否為閏年
21
date and timedelta of datetime module
timedelta 用來運算日
期時間
23
combine() of datetime module
combine 後的 datetime
object
一樣可以再利用 date(), time()
24
time module
mktime():converts a struct_time
object to epoch seconds
25
strftime()
strftime() converts a struct_time object to a string
and uses format strings to specify the output
數字左邊補 26
strptime()
strptime() converts a string to a struct_time object
and uses the same format string
數字左邊補 27
locale
locale—internationalization settings for your operating system
28
練習題
Book P.259
Things to Do 10.7~10.9
29