易截截图软件、单文件、免安装、纯绿色、仅160KB

python time模块详解

 python 的内嵌time模板翻译及说明
 
一、简介
  time模块提供各种操作时间的函数
  说明:一般有两种表示时间的方式:
       第一种是时间戳的方式(相对于1970.1.1 00:00:00以秒计算的偏移量),时间戳是惟一的
       第二种以数组的形式表示即(struct_time),共有九个元素,分别表示,同一个时间戳的struct_time会因为时区不同而不同
    year (four digits, e.g. 1998)
    month (1-12)
    day (1-31)
    hours (0-23)
    minutes (0-59)
    seconds (0-59)
    weekday (0-6, Monday is 0)
    Julian day (day in the year, 1-366)
    DST (Daylight Savings Time) flag (-1, 0 or 1) 是否是夏令时
    If the DST flag is 0, the time is given in the regular time zone;
    if it is 1, the time is given in the DST time zone;
    if it is -1, mktime() should guess based on the date and time.
    夏令时介绍:http://baike.baidu.com/view/100246.htm
    UTC介绍:http://wenda.tianya.cn/wenda/thread?tid=283921a9da7c5aef&clk=wttpcts
    
二、函数介绍
1.asctime()
  asctime([tuple]) -> string
  将一个struct_time(默认为当时时间),转换成字符串
        Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
        When the time tuple is not present, current time as returned by localtime()
        is used.
        
2.clock()
  clock() -> floating point number
  该函数有两个功能,
  在第一次调用的时候,返回的是程序运行的实际时间;
  以第二次之后的调用,返回的是自第一次调用后,到这次调用的时间间隔
 
  示例:
  import time
if __name__ == '__main__':
time.sleep(1)
print "clock


相关文档:

Python安装MySQLDb模块的种种问题及解决


我的环境是:Linux version 2.4.21-4.EL
(bhcompile@daffy.perf.redhat.com) (gcc version 3.2.3 20030502 (Red Hat
Linux 3.2.3-20)) #1 Fri Oct 3 18:13:58 EDT 2003 + Python2.6.4
本文结合我安装时候的问题,总结而成
用户目录如/home/liuguanyu/ , 保证用户有root权限
1,看看有没有安装
 &nbs ......

python动态导入模块、检查模块是否安装

参考链接:http://www.woodpecker.org.cn/diveintopython/functional_programming/dynamic_import.html
一 动态导入模块
Python的import不能接受变量,所以应该用 __import__函数来动态导入。
如下的代码无法正常导入模块
modules = ['OpenSSL', 'Crypto', 'MySQLdb', 'sqlite3', 'zope.interface', 'pyasn1', 'twisted ......

python中import自己写的模块

只需要在文件中import与你写的文件的文件名一致的模块名即可,这时python会为你创建一个pyc文件的。
即,如果你已经写了一个名为ssss.py的文件,而现在你需要在名为aaaa.py的文件中使用ssss.py中定义的方法,那么你只需要在aaaa.py中加入import ssss,然后你就可以在aaaa.py中使用ssss.py中的方法(当然方法前需要加模块名 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号