【发布时间】:2012-08-11 23:50:54
【问题描述】:
我是 turbogears 的新手,我正在使用 public/media/ballots 下的多个目录创建一个应用程序。我需要看看一个目录是否存在。
path = "public/media/ballots/" + x['directoryName']
#return path
if os.path.exists(path):
listing = os.listdir(path)
i=0
for infile in listing:
#find path for ballot1, ballot2, etc from files in directory
i +=1
Ballot = "Ballot" +str(i)
x['Ballot']= infile
return x
else:
return "false"
我尝试了多种定义路径的方法:“/media/ballots/”、“./media/ballots/”、“media/ballots”。但是 os.path.exists(path) 总是返回 false。我不确定 TG 是如何访问公共文件的。
【问题讨论】:
标签: path turbogears