Python obtains the 13-bit unix timestamp, 13-bit Python

Source: Internet
Author: User

Python obtains the 13-bit unix timestamp, 13-bit Python

When developing a web program in python, you must call a third-party interface and sign the request. Unix timestamp is required.
In python, many methods are introduced online, and the timestamp is 10 bits. In java, the default value is 13 BITs (milliseconds in milliseconds ).

The following describes how to obtain the timestamp in python:

1. 10 timestamp acquisition method:

>>> Import time >>> t = time. time () >>>> print t1436428326.76 >>> print int (t) 1436428326 >>>

Forced conversion directly removes decimal places.

2. 13-bit timestamp acquisition method:

(1) by default, the python timestamp is a float output in seconds.

>>>>>> Import time >>> time. time () 1436428275.207596 >>>

Get the 13-bit timestamp by converting the second to the millisecond:

Import timemillis = int (round (time. time () * 1000) print millis

Round () is rounding.

(2)

Import timecurrent_milli_time = lambda: int (round (time. time () * 1000) Then: >>> current_milli_time () 1378761833768

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.