【发布时间】:2018-11-14 07:21:34
【问题描述】:
我有一个函数可以读取名为“游戏”的目录并在其中查找某些文件。这部分工作正常。问题是我想计算有多少个文件,每个文件我想将 10 添加到一个变量中。
def games():
f = 0
sy = 100
ftext = pygame.font.SysFont("Arial", 20)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
screen.fill(DarkSpace)
ToolBarButton("Home", 0, 0, 150, 50, SpaceGrey, CornflowerBlue, 10, cmain)
ToolBarButton(username, 153,0,150,50, SpaceGrey, CornflowerBlue, 10, accountDetails)
ToolBarButton("Programs", 305,0,150,50, SpaceGrey, CornflowerBlue, 10, programs)
ToolBarButton("Games", 458,0,150,50, SpaceGrey, CornflowerBlue, 10, games)
ToolBarButton("Help", 610,0,150,50, SpaceGrey, CornflowerBlue, 10, hel)
DropDown(NeonGreen, CornflowerBlue, 764, 16, 30, 30, DropMenu)
Btext(screen, "Loading Games!", CornflowerBlue, ftext, 600,600,600,600)
fileDir = os.listdir(r"D:\Users\26099\Desktop\Programming\Dark_Dragons\Blunt_Wars1\venv\Launcher\Games")
nf = len(fileDir)
while nf > f:
f += 1
sy += 10
break
print(sy)
for fileN in fileDir:
verif = fileN.endswith('.py') or fileN.endswith('.pyw')
if not verif:
fileDir.remove(fileN)
else:
print(fileN)
text(screen, fileN, CornflowerBlue, ftext, 300,sy)
pygame.display.update()
所以我想为每个具有特定扩展名的文件添加 100 到 sy。我尝试将其放入 for 循环中,但出现错误说 int object is not callable 所以有人知道如何处理这个
【问题讨论】:
标签: python-3.x file variables pygame