Python -Zeitcode
import time
t0 = time.time()
code_block
t1 = time.time()
total = t1-t0
Difficult Dunlin
import time
t0 = time.time()
code_block
t1 = time.time()
total = t1-t0
import time
start = time.time()
print("hello")
end = time.time()
print(end - start)
# Here is a self updating clock function, just run it and it'll self update itself until you hit CTRL-C
import datetime
import time
def clock():
while True:
print(datetime.datetime.now().strftime("%H:%M:%S"), end="\r")
time.sleep(1)
clock()
from datetime import datetime, timezone
print(datetime.now()) # timezone
print(datetime.now(timezone.utc)) # coordinated universal time
#!/usr/bin/python
import time
t = (2009, 2, 17, 17, 3, 38, 1, 48, 0)
t = time.mktime(t)
print time.strftime("%b %d %Y %H:%M:%S", time.gmtime(t))
#!/usr/bin/python
import time
t = (2009, 2, 17, 17, 3, 38, 1, 48, 0)
t = time.mktime(t)
print time.strftime("%b %d %Y %H:%M:%S", time.gmtime(t))
OUTPUT:Feb 18 2009 00:03:38