forked from flypythoncom/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathospathex.py
38 lines (30 loc) · 813 Bytes
/
ospathex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
for tmpdir in("/tmp"):
if os.path.isdir(tmpdir):
break
else:
print "no temp dir available"
tmpdir = ""
if tmpdir:
os.chdir(tmpdir)
cwd = os.getcwd()
print " current tmp dir"
print cwd
print "create example dir"
os.mkdir("example")
os.chdir("example")
cwd = os.getcwd()
print "new work dir"
print cwd
print "list the dir"
print os.listdir(cwd)
print "create test file"
fobj = open("test","w")
fobj.write("xxg\n")
fobj.write("111111")
fobj.close()
print "update the list dir"
print os.listdir(cwd)
print "rename the file"
os.rename("test","xxg.txt")
print os.listdir(cwd)