Snowdream

I'm awake but my world is half asleep
posts - 388, comments - 215, trackbacks - 0, articles - 7
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Python 学习 - File and Directory

Posted on 2007-08-15 22:34 ZelluX 阅读(133) 评论(0)  编辑  收藏 所属分类: Scripting

1. 几个常用对象:
os.system  执行命令
sys.stdin  sys.stdout
os.path.getsize   获得文件大小
os.path.isdir
os.mkdir
os.listdir

2. walk()函数
很好用的一个函数
os.path.walk(rootdir, f, arg)
rootdir是要访问的目录树的根,f是用户定义的函数,arg是调用f时用的一个参数。
对于每一个"walk"过程中遇到的目录directory,设该目录下的文件列表为filelist,walk函数会调用
f(arg, directory, filelist)


标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
 
相关链接:
网站导航: