1
我正在使用下面的代碼從mysql
獲取名爲fajr_begins
的時間實體。我能夠打印fajr_begins
它的格式是:5:27:00,我如何將它轉換爲Python中的時間格式,以便我可以操縱時間並添加15分鐘?使用python從mysql獲取時間
cnx = mysql.connector.connect(host=mysql_remote_host, user=mysql_remote_host_user, password=mysql_remote_host_password, database=mysql_remote_host_database)
cursor = cnx.cursor()
cursor.execute("select * from prayertimes where DATE(date) = DATE(NOW())")
results = cursor.fetchall()
id, date, fajr_begins, fajr_jamaat, sunrise, zuhr_begins, zuhr_jamaat, asr_begins, asr_jamaat, maghrib_jamaat, isha_begins, isha_jamaat = results[0]
cursor.close()
print fajr_begins
有Python中的時間實例,而不日期 – Ossama
是,Python有'time'模塊,但ü不能做到像'add'分鐘,小時,天等.... timedelta不能添加timetuple直接操作。 – Nilesh
謝謝,所以我想我需要轉換回時間一次我加15分鐘 – Ossama