2009-12-15 15 views
7

Aşağıdaki koddan milisaniyeler nasıl hesaplanır. Yenipython süresi (mili saniye) hesaplaması

a = datetime.datetime.now() 
b = datetime.datetime.now() 
c = b - a 

>>> c 

>>> c.days 
0 
>>> c.seconds 
4 
>>> c.microseconds 
+0

related: [? Python milisaniye cinsinden cari zaman alın] (http://stackoverflow.com/ q/5998245/4279) – jfs

cevap

11
milliseconds = (c.days * 24 * 60 * 60 + c.seconds) * 1000 + c.microseconds/1000.0 
+0

Bu cevap yanlış! Eğer zaman deltası tam 1 dakika ise, sonuç 0 olacak, bizim beklentimiz değil! – starkshang

İlgili konular