# -*- coding: utf-8 -*-
#!/usr/bin/python

# google 搜尋 python 取得檔案列表
# google 搜尋 python 取得附檔名

from os import listdir
from os.path import dirname, join, isfile, isdir, splitext
import sys

def myDir(dir):
   # 取得所有檔案與子目錄名稱
   files = listdir(dir)

   for f in files:
      # 產生檔案的絕對路徑
      fullPath = join(dir, f)
      # 判斷 fullPath 是檔案還是目錄
      if isfile(fullPath):
         print("檔案：", f)
#         print(splitext(f))
      elif isdir(fullPath):
         print("目錄：", f)
         myDir(fullPath)

# main
print('[' + dirname(__file__) + ']')
print(sys.path[0])
myDir(sys.path[0])

input('Press enter to continue......')
