【发布时间】:2021-03-09 08:14:22
【问题描述】:
在这段代码中,我得到了一个存在于基本路径中的路径,它正确地获取了路径,但问题是我想将该函数保存在另一个名为 hi 的变量中,但每当我打印它时,它给了我结果None
import os
def contain(dirname, dPath):
dirfiles = os.listdir(dirname)
fullpaths = map(lambda name: os.path.join(dirname, name), dirfiles)
dirs = []
for file in fullpaths:
if os.path.isdir(file): dirs.append(file)
folder = list(dirs)
watching = [s for s in folder if dPath in s]
copy = str(watching)[2:-2]
print(copy)
def hello():
base = '/home/bilal/Videos/folder1'
destination = '/home/bilal/Videos/folder1/fd'
hi = contain(base, destination)
print(f"This is another time: {hi}")
hello()
【问题讨论】:
标签: python