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