Python:easygui,如何选择多个文件?

Ric*_*cky 3 python easygui

我正在使用 fileopenbox() 并且我想在 Windows 框打开时选择我拥有的所有文本文件。我试过按 shift 或 ctrl + A,但没有用。

openfile = fileopenbox("Welcome", "COPR", filetypes= "*.txt")
Run Code Online (Sandbox Code Playgroud)

小智 5

如果在参数中包含multiple=True,则可以选择多个文件:

openfiles = fileopenbox("Welcome", "COPR", filetypes= "*.txt", multiple=True)
Run Code Online (Sandbox Code Playgroud)

请注意,现在 fileopenbox 将返回的不是字符串,而是字符串列表,例如:

["foo.txt", "Hello.txt", "mytxt.txt"]


mad*_*jar 1

Easygui 是不可能的。您可以做的是重用easygui 中的代码(参见第 1700 行)并稍微修改它以使用askopenfilenames而不是askopenfilename.