Four ways of 15.python-import module __python

Source: Internet
Author: User
Tags local time


Import time refers to the import time module, which can be taken from Python , or it can be installed on its own, such as the use of numpy modules, which need to be installed themselves.


method One: Import time

Import Time

Print (Time.localtime ()) #这样就可以print local time.

""""

Time.struct_time (tm_year=2016, tm_mon=12, tm_mday=23, tm_hour=14, tm_min=12, tm_sec=48, tm_wday=4, tm_yday=358, tm_ isdst=0)

""""


method Two: Import time as __,__ the underline abbreviation section can be defined by itself, in the code to define time as T.

import time as T

Print (T.localtime ()) # needs to be prefixed with a T. prefix to Elicit functionality

""""

Time.struct_time (tm_year=2016, tm_mon=12, tm_mday=23, tm_hour=14, tm_min=12, tm_sec=48, tm_wday=4, tm_yday=358, tm_ isdst=0)

""""


method Three: From time import time,localtime, only import the function you want.

from time to import time, localtime

Print (LocalTime ())

Print (Time ())

""""

Time.struct_time (tm_year=2016, tm_mon=12, tm_mday=23, tm_hour=14, tm_min=41, tm_sec=38, tm_wday=4, tm_yday=358, tm_ isdst=0)

1482475298.709855

""""


method Four: From time import * All functions of input module

from time import *

Print (LocalTime ())

""""

Time.struct_time (tm_year=2016, tm_mon=12, tm_mday=23, tm_hour=14, tm_min=41, tm_sec=38, tm_wday=4, tm_yday=358, tm_ isdst=0)

""""




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.