第一题题目没看明白,不清楚要做什么、 第二题: import os
def findPath(s): #s:指定字符串 for n in os.listdir(): #遍历当前路径下所有文件 if n.find(s) >= 0: #若文件不包含函数传入字符串,会返回-1 print (os.path.realpath(n)) #os.path.realpath()返回指定文件的标准路径
Sign in to make a reply
Pmz丶
第一题题目没看明白,不清楚要做什么、 第二题: import os
def findPath(s): #s:指定字符串 for n in os.listdir(): #遍历当前路径下所有文件 if n.find(s) >= 0: #若文件不包含函数传入字符串,会返回-1 print (os.path.realpath(n)) #os.path.realpath()返回指定文件的标准路径