mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-28 20:42:33 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
import os
|
||||
|
||||
```
|
||||
@@ -26,14 +26,14 @@ import os
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.getcwd()
|
||||
|
||||
```
|
||||
|
||||
Out[2]:
|
||||
|
||||
```
|
||||
```py
|
||||
'/home/lijin/notes-python/05\. advanced python'
|
||||
```
|
||||
|
||||
@@ -41,14 +41,14 @@ Out[2]:
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.curdir
|
||||
|
||||
```
|
||||
|
||||
Out[3]:
|
||||
|
||||
```
|
||||
```py
|
||||
'.'
|
||||
```
|
||||
|
||||
@@ -56,14 +56,14 @@ Out[3]:
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.listdir(os.curdir)
|
||||
|
||||
```
|
||||
|
||||
Out[4]:
|
||||
|
||||
```
|
||||
```py
|
||||
['05.01 overview of the sys module.ipynb',
|
||||
'05.05 datetime.ipynb',
|
||||
'05.13 decorator usage.ipynb',
|
||||
@@ -88,7 +88,7 @@ Out[4]:
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
f = open("test.file", "w")
|
||||
f.close()
|
||||
|
||||
@@ -96,7 +96,7 @@ print "test.file" in os.listdir(os.curdir)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
True
|
||||
|
||||
```
|
||||
@@ -105,7 +105,7 @@ True
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.rename("test.file", "test.new.file")
|
||||
|
||||
print "test.file" in os.listdir(os.curdir)
|
||||
@@ -113,7 +113,7 @@ print "test.new.file" in os.listdir(os.curdir)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
False
|
||||
True
|
||||
|
||||
@@ -123,7 +123,7 @@ True
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.remove("test.new.file")
|
||||
|
||||
```
|
||||
@@ -134,7 +134,7 @@ os.remove("test.new.file")
|
||||
|
||||
In [8]:
|
||||
|
||||
```
|
||||
```py
|
||||
# windows 为 \r\n
|
||||
os.linesep
|
||||
|
||||
@@ -142,7 +142,7 @@ os.linesep
|
||||
|
||||
Out[8]:
|
||||
|
||||
```
|
||||
```py
|
||||
'\n'
|
||||
```
|
||||
|
||||
@@ -150,14 +150,14 @@ Out[8]:
|
||||
|
||||
In [9]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.sep
|
||||
|
||||
```
|
||||
|
||||
Out[9]:
|
||||
|
||||
```
|
||||
```py
|
||||
'/'
|
||||
```
|
||||
|
||||
@@ -165,14 +165,14 @@ Out[9]:
|
||||
|
||||
In [10]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.pathsep
|
||||
|
||||
```
|
||||
|
||||
Out[10]:
|
||||
|
||||
```
|
||||
```py
|
||||
':'
|
||||
```
|
||||
|
||||
@@ -182,14 +182,14 @@ Out[10]:
|
||||
|
||||
In [11]:
|
||||
|
||||
```
|
||||
```py
|
||||
os.environ["USER"]
|
||||
|
||||
```
|
||||
|
||||
Out[11]:
|
||||
|
||||
```
|
||||
```py
|
||||
'lijin'
|
||||
```
|
||||
|
||||
@@ -201,7 +201,7 @@ Out[11]:
|
||||
|
||||
In [12]:
|
||||
|
||||
```
|
||||
```py
|
||||
import os.path
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user