How can I obtain the names of files within a folder in QT?

To access the names of files within a folder, you can use the listdir() function in the os module in Python.

Here is an example code:

import os

folder_path = "文件夹的路径"

file_names = os.listdir(folder_path)

for name in file_names:
    print(name)

Replace “folder path” with the desired folder path where you want to get the file names, then run the code to obtain the names of the files within the folder.

bannerAds