一、os.path相关
def find_file(path):
name_list = os.listdir(path)
for name in name_list:
# 拼接具体的文件路径
abs_path = os.path.join(path, name)
if os.path.isfile(abs_path):
print(name)
elif os.path.isdir(abs_path):
find_file(abs_path)
示例2:
import os
BASE_PATH = os.path.dirname(os.path.dirname(__file__))
print(BASE_PATH)
原文:https://www.cnblogs.com/messi-mu/p/13960466.html