import os
import glob
path = input("Please enter the directory you want to get the files from. -> ")
for filename in glob.glob(os.path.join(path, '*.ppm')):
open("r", encoding="utf-8")
我正在尝试打开用户指定目录中的所有.ppm文件。
答案 0 :(得分:1)
您一直在尝试打开一个名为" r"的文件。尝试添加文件名。
import os
import glob
path = input("Please enter the directory you want to get the files from. -> ")
for filename in glob.glob(os.path.join(path, '*.ppm')):
file_obj = open(filename, "r", encoding="utf-8")