# -*- coding:UTF-8 -*-
import os
print 'current path is:',os.getcwd()
try:
? ? ?os.mkdir('testdir')
except:
? ? ?print'testdir is exist'
else:
? ? ?pass
#注意路徑的“\”需要轉(zhuǎn)義
os.chdir('D:\\myprogram\\python_study\\testdir')
print 'current path is: %s after change dir' %os.getcwd()
#如果直接創(chuàng)建制定路徑的文件,對于路徑需要轉(zhuǎn)義,或者在文件名前加r,表示
f = open(r'D:\ttestfile','w')
f.write('test write to file!' + '\n')
f.close()
