Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

การได้เวลาที่จัดรูปแบบ (Getting formatted time) ใน Python

คุณสามารถจัดรูปแบบเวลาใดๆ ตามที่คุณต้องการ แต่วิธีง่ายที่สุดในการได้เวลาในรูปแบบอ่านได้คือ asctime():

ตัวอย่าง

#!/usr/bin/python
import time
localtime = time.asctime(time.localtime(time.time()))
print "Local current time :", localtime

ผลลัพธ์ (Output)

นี่จะผลิตผลลัพธ์ดังนี้:

Local current time : Tue Jan 13 10:17:09 2009