看板 [ Python ]
討論串[問題] 請問該怎麼改寫這段CODE
共 4 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者beatitude (...)時間13年前 (2012/03/15 00:09), 編輯資訊
0
0
0
內容預覽:
引述《kilfu0701 (( ̄ー+ ̄)キラリ)》之銘言:. def getDir(path, depth, current=0, tmp=[]):. if current >= depth:. return tmp. # Return a list containing the names o
(還有250個字)

推噓0(0推 0噓 1→)留言1則,0人參與, 最新作者kadodo (想辦法突破)時間13年前 (2012/03/14 17:21), 編輯資訊
0
0
0
內容預覽:
tmp2 = getDir(root, depth). all = [tmp2[j][0] for j in range(len(tmp2)) if tmp2[j][1]==depth-1]. 首先感謝你的答覆~~~. 我修改了一點點得到了我想要的結果. 我還有個問題是 在getDir裡面呼叫自己的

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者kilfu0701 (( ̄ー+ ̄)キラリ)時間13年前 (2012/03/14 12:24), 編輯資訊
0
0
0
內容預覽:
我是用recursive加上depth去紀錄跑到哪一層. 以下是範例,可能寫的不好 XD. def getDir(path, depth, current=0, tmp=[]):. if depth <= current:. return tmp. dirs = os.listdir(path).
(還有211個字)

推噓0(0推 0噓 2→)留言2則,0人參與, 最新作者kadodo (想辦法突破)時間13年前 (2012/03/14 10:56), 編輯資訊
0
0
0
內容預覽:
#!/usr/bin/env python3. import os, time. root = "/home/myhome". def get_dirs_parent(parent_dir):. l1_all = []. des_dir = os.listdir(parent_dir). for i
(還有978個字)
首頁
上一頁
1
下一頁
尾頁