pyqt5 getdate
时间: 2023-07-30 13:08:29 浏览: 165
To get the current date in PyQt5, you can use the QDate class from the QtCore module. Here's an example of how you can do it:
```python
from PyQt5.QtCore import QDate
# Get the current date
current_date = QDate.currentDate()
# Print the date
print(current_date.toString("yyyy-MM-dd"))
```
In this example, the `currentDate()` method of the `QDate` class returns a `QDate` object representing the current date. The `toString()` method is then used to convert the `QDate` object to a string format ("yyyy-MM-dd" in this case), which can be printed or used in other ways as needed.
阅读全文