我想做的事
进入用户选择的文件夹,然后向他们展示该文件夹中的文件
我多么希望我这样做
我想向用户显示文件列表和它们所在的文件夹,然后允许用户选择一个。
代码
我试过这个:
#!/usr/bin/env python
import os, sys, glob
os.chdir(glob.glob("/var/mobile/TP/")[0])
print("Please select a Texture Pack (##):")
items = os.listdir(".")
i = 1
for item in items:
print("[%.2d] %s" % (i, item))
i += 1
#And then something that will assign the variables to the listed items, like
*firstlisteditem*=a ; *secondlisteditem*=b #... and so on
#and then i need to get the user to tell me which folder he wants to go to. This I will do using a number.
se=raw_input ()
if "1" in se then
exec /var/mobile/TP/$a
if "2" in se then
exec /var/mobile/TP/$b