Category:PyQt5
Article From:https://www.cnblogs.com/zhuluqing/p/9064846.html

1. QFileDialog

Used to pop up or save the dialog box, and then return the selected file or folder.

1.You can filter the type of file you need

2.Can be set for multiple selection

3.Can be set to save or open

Two, QFileInfo

Saving file related information is usually obtained in two ways: 1. initializing QFileInfo (path); 2.QDirIterator.fileInfor ()

If you need to get the relevant information of the file, you need this class.,Such as:

Does the file exist, file size, modification time, readable, file type (folders, files, hyperlinks, executable files, hidden files, and point files)

Three, QDirIterator

This class is used to iterate files in directory, and automatically search files in multi-level directory, so it is much more convenient than using QDir. It is recommended to use this class.

dirIterator=QDirIterator(path,QDir.Files|QDir.Dirs|QDir.NoDotAndDotDot|QDir.NoSymLinks,QDirIterator.Subdirectories)
while dirIterator.hasNext():
dirIterator.next()
   fileInfo=dirIterator.fileInfo()
Four, QDir
Represents a directory that is used to process directories.
Five, QFile
For file content reading, mainly text files and binary files, it is better to bring open () function with Python.
In addition, Python's own modules OS and os.path can also process files.

Leave a Reply

Your email address will not be published. Required fields are marked *