赞
踩
from tkinter import filedialog
img_path = filedialog.askopenfilename()
print(img_path)
from tkinter.filedialog import askopenfilename, asksaveasfilename
''' 打开图像文件路径 ''' def open_imgfile(): img_path = askopenfilename( title='请选择图片文件', # 筛选常见图片文件 filetypes=[('图片', '.jpg .png .gif .bmp .jpeg')], ) if img_path and img_path.endswith(('.jpg', '.png', '.gif', '.jpeg', '.bmp')): # 图像路径 path = img_path
from tkinter.filedialog import askdirectory
dir = askdirectory(title='请选择文件夹',)
print(dir)
from tkinter.filedialog import askopenfilename,askdirectory
def openfile():
file_path = askopenfilename(title='请选择文件')
return file_path
def opendir():
dir_path = askdirectory(title='请选择文件夹')
return dir_path
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。