首页 › 日存档 › 2010年04月16日

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
继续阅读 »

再来一个PYTHON小应用:天气查询

还是学校那个项目,终于想清楚了,打算提供个查询学校状况的飞信机器人给最终用户。
这两天玩PyFetion玩的很爽,自己对照给的例子也写了个 小客户端
打算加入天气情况的定时发送。从网上找了几份代码,都不是很满意,从百度手机版找到了天气,下载下来粗看一下,行,不用正则表达式(软 肋)就能解析,于是用半个多小时搞定~上次弄了个字典的,呵呵
不说废话了,贴代码:

继续阅读 »