易截截图软件、单文件、免安装、纯绿色、仅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的一些操作

# coding=gb2312
# 用中文注释前务必加上第一行
# 求模运算符,和C语言一样
print 10%9
# 整数相除仍然是整数
print 5/2
# 2后加上.就变成浮点数了
print 5/2.
# **表示求幂运算
print 7**4
# 函数用时要加上module.function
import math
print math.floor(19.8)
# 函数名也可以成为变量
func = math.floor
......

Python模块随想随记

时常见到一些好的Python模块,如果不随时记下,等用的时候又是一阵乱翻,好在Python引用一个模块极其方便,OK,废话少说:
1. decimal
标准模块,2.4引入,用于浮点数的精确表示:
>>> 0.1 + 0.1 + 0.1 - 0.3
5.5511151231257827e-17
>>> from decimal import Decimal
>>> def _(x): retu ......

用Python写的图片蜘蛛人


    写了个图片蜘蛛人玩玩,抓了几个网页试试,感觉不不错。核心的代码可能20行也不到,简洁明了,嘻嘻。废话少说,翠花,上代码~~
#coding=utf-8
import os
import sys
import re
import urllib
URL_REG = re.compile(r'(http://[^/\\]+)', re.I)
IMG_REG = re.compile(r'<img[^>]*?src=([ ......

Python与Microsoft Office自动化操作

http://www.cnblogs.com/Jedimaster/archive/2007/02/28/660209.html
  朋友的家人做生意,每日从各地分店处收集报表,然后回去汇总。由于不想用那种复杂的管理软件,就叫他写一个小工具。于是他找到了我,让我想想办法。
  Python是个令人惊奇的工具,而不仅仅是一种语言。对比老牌的Perl,看似Python不是那么的精通 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号