我正在python的nooby,似乎无法让我的程序做我想做的。我希望用户指定他们想要打开的.gif文件,然后程序将显示他们指定的.gif
。不知道我做错了什么。如果有人能帮助我,我将不胜感激。我希望他们指定文件,程序然后将文件重命名为文件夹中的“变量”。打开文件在/path/path/variable.gif
打开文件用户指定
files = listdir(".")
print("List of GIF files in Directory:")
for f in files:
if f[-4:] == ".gif":
print(f)
print("type quit to close the program")
gif1 = input("type which .gif you would like to modify and press enter:")
infile = open(gif1, "r")
outfile= open("gif1.gif", "w")
os.system('eog {0}'.format(r'home/pictures/gif1'))
Arrite,我正在处理这个问题。 –
http://docs.python.org/2/library/os.html#os.rename – dm03514
在glob.glob('* .gif')中使用'for f:如果您只需要'.gif',则使用print f'文件。 –