gpt4 book ai didi

How can I open an srt format in Flet File Picker?(如何在Flet文件拾取器中打开SRT格式?)

转载 作者:bug小助手 更新时间:2023-10-28 10:56:59 26 4
gpt4 key购买 nike



I want to pick an SRT Format file in Flet File Picker. But document said I can only open IMAGE, VIDEO, MEDIA, AUDIO and Custom files. And in front of Custom, they wrote this:
'only files with extensions from allowed_extensions list'

我想在Flet文件拾取器中拾取一个SRT格式的文件。但文件说我只能打开图像、视频、媒体、音频和自定义文件。在Custom前面,他们写道:“只有扩展名来自Allowed_Exages列表的文件。”


I checked the allowed list, and they wrote this "allowed_extensions

我检查了允许的列表,他们写道:“允许的扩展


Allow picking files with specified extensions only.
The value of this property is a list of strings, e.g. ["PDF", "SVG", "JPG"]."

仅允许拾取具有指定扩展名的文件。该属性的值是一个字符串列表,例如[“PDF”,“SVG”,“JPG”]。“


How can I use this feature?

如何使用此功能?


First i tried this :

首先,我尝试了这个:


on_click = lambda _: filepicker.pick_files(dialog_title = "Choose the subtitle",
file_type = flet.FilePickerFileType.CUSTOM['srt'],
allow_multiple = False))

but i got this error:

但我得到了这样的错误:


TypeError: 'FilePickerFileType' object is not subscriptable

TypeError:“FilePickerFileType”对象不可订阅


更多回答
优秀答案推荐

The error you are getting is because you are trying to access the srt element of the FilePickerFileType.CUSTOM Enum as a dictionary, but it is actually an enum type.
in the documentation is described:

您收到的错误是因为您试图访问作为字典的FilePickerFileType.CUSTOM Enum的SRT元素,但它实际上是一个枚举类型。文档中介绍了以下内容:



FilePickerFileType enum with the following values:


ANY (default) - any file
IMAGE
VIDEO
MEDIA - VIDEO and IMAGE
AUDIO
CUSTOM - only files with extensions from allowed_extensions list


https://flet.dev/docs/controls/filepicker/

Https://flet.dev/docs/controls/filepicker/


To fix this, you need to change the code to:

要解决此问题,您需要将代码更改为:


on_click = lambda _: filepicker.pick_files(dialog_title = "Choose the subtitle",
file_type = flet.FilePickerFileType.CUSTOM,
allowed_extensions = ["srt"],
allow_multiple = False))

更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com