1. 程式人生 > >python 檔案操作知識總結: 獲取當前路徑

python 檔案操作知識總結: 獲取當前路徑

1. python

獲取當前所在路徑:

os.getcmd()

獲取當前路徑下的檔案數:

方法一:(已驗證)

sum([len(files) for root,dirs,files in os.walk(dir)])
方法二:(未驗證)

count =0

for filename in os.listdir(os.getcmd()):

 count += 1