time - alternative to total_seconds() in python 2.6 -


The total_seconds () method in Python 2.7 is.

In Python 2.6, it does not exist and is suggested to use

  (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / 10 ** 6  

Can anyone show me how to implement it?

Thank you

  import datetime timestamp = '2014-10-24 00:00:00' timestamp = Int ((datetime.datetime.strptime (timestamp, '% Y-% m-% d% H:% M:% S ') - Daytime Datetime (1970,1,1). Total_second ()) Print timestamp timestamp =' 2014-10-24 00:00:00 "timestamp = datetime.datetime.strptime (timestamp, '% Y-% m-% d% H:% M:% S') - datetime.datetime (1970,1,1) Print timestamp  

Here it is a timeliness_all_social function and using 2.7 you can see that this is the total_user Using reservoir method to achieve the same output.

  import datetime def timedelta_total_seconds (timeliness): Return (Taimdeltakmicrosukend + 0.0 + (Taimdeltaksekands + Taimdelta DAS * 24 * 3600) * 10 ** 6) / 10 ** 6 timestamp = '2014-10-24 00:00:00' Taim_delta = Datetimekdatetimekstrptime (timestamp, '% Y-% m-% d% H:% M:% S') - Date time Ktataim (1 9, 70, 1, 1) print time-Taimtata_tata_ seconds (Taim_delta) Print Smay_deta_takod ()  

output

  1414108800.0 1414108800.0  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -