仅列出标题 列出摘要

python os一些相关操作

 1 import os
  2 path = os.path.join(os.path.expanduser("~"),"a.log")
  3 filepath, filename = os.path.split(path)
  4 a,b = os.path.splitext(filename)
  5 print a,b
  6 for fname in os.listdir("/root/Desktop"):
  7     #if os.path.isfile(os.path.join("/root/Desktop",fname)):
  8     if os.path.isdir(os.path.join("/root/Desktop",fname)):
  9         print fname

posted on 2013-01-19 16:06  baoyiluo  阅读(127)  评论(1编辑  收藏  举报