Discuss / Python / window下可能会出行路径错误,换个文件夹测试正常

window下可能会出行路径错误,换个文件夹测试正常

Topic source

东东男装

#1 Created at ... [Delete] [Delete and Lock User]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os

def dirs(key,pat):
    for f in os.listdir(pat):
        if os.path.isfile(f):
            str = os.path.split(f)[1].split('.')
            if key in str[0]:
                print(str[0])
        if os.path.isdir(f):
            pat = os.path.join(pat,f)
            dirs(key,pat)

pwd = os.path.abspath('.')
dirs('t',pwd)

东东男装

#2 Created at ... [Delete] [Delete and Lock User]

第二题的


  • 1

Reply