python中os模块常用方法
#!/usr/bin/python
## os module test
import os
print 'os.name: ', os.name
print 'os.getcwd(): ', os.getcwd()
print '''========================================='''
print 'os.getenv(\'path\'): ', os.getenv('path')
print '''========================================='''
print 'os.listdir(\'f\'): ', os.listdir('f:');
print 'os.path.isdir(\'d:\\python27\')', os.path.isdir('d:\\python27')
print 'os.path.isfile(\'d:\\python27\\xlb.py\')', os.path.isfile('d:\\python27\\xlb.py')
print 'os.path.exists(\'d:\\python27\')', os.path.exists('d:\\python27')
##这个厉害, 执行系统命令
print 'os.system(\'cmd\'): ', os.system('cmd /k net user')

浙公网安备 33010602011771号