Frage

I have a question about PyQt4. I have a date that is of a type QDate and I want to simply turn it into a string format as opposed to QDate format. For example, if the date is 09/16/2013, I would want to change it into a string form of September 16, 2013 if possible.

I played around with toString but I think that only works with C++ (unless I am mistaken).

War es hilfreich?

Lösung

Documentation is your friend ;)

>>> date = QtCore.QDate.fromString('20130916', 'yyyyMd')

# PySide
>>> date.toString('MMMM d, yyyy')
u'September 16, 2013'

# PyQt4
>>> date.toString('MMMM d, yyyy')
PyQt4.QtCore.QString(u'September 16, 2013')
>>> unicode(date.toString('MMMM d, yyyy'))
u'September 16, 2013'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top