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

关于Python中时间与字符串直接的转换

>>> import time
>>> import datetime
>>>
now = time.localtime()
>>> now
(2006, 4, 30, 18, 7, 35,
6, 120, 0)
>>> type(now)
<type 'time.struct_time'>
>>>
str_now = time.strftime("%m/%d/%Y %X", now )
>>>
str_now
'04/30/2006 18:07:35'
>>> new_now =
time.strptime( str_now, "%m/%d/%Y %X" )
>>> new_now
(2006,
4, 30, 18, 7, 35, 6, 120, -1)
这里,strftime 将 struct_time 的时间按指定的格式转化成 字符串
strptime 将 字符串按指定的格式转化成
struct_time 的时间
struct_time 的时间没有现成的比较的函数,可以将 struct_time 转化成 datetime.datetime
>>> d_now = datetime.datetime( *now[:6] )
>>>
type(d_now)
<type 'datetime.datetime'>
>>> d_now
datetime.datetime(2006,
4, 30, 18, 7, 35)


相关文档:

手动制作python的exe可执行程序


1. 手动制作python的exe可执行程序
                                      转载---------------
Python没有内建一个编 ......

用Python提取文件夹下的特定扩展名的文件

                用Python提取文件夹下的特定扩展名的文件
      不知道什么时候,网闲着没用,挂了个linux的视屏教程,里面有很多个文件夹,有很多无关的文件。这对于像我没收藏垃圾文件癖好的人来说,简直是 ......

深入Python摘要

英文版Dive in python可以在下面找到中文翻译http://linuxtoy.org/docs/dip/toc/index.html
模块的__name__,当模块被import时,其为模块的名字,当模块作为main执行的时候,其为__main__
词典的key是大小写敏感的。
List也支持重载+操作,用于将两个list连接起来,并返回一个List,因此它没有extended执行高效。list也+ ......

python中package机制的两种实现方式


当执行import
module时,解释器会根据下面的搜索路径,搜索module1.py文件。
1) 当前工作目录
2) PYTHONPATH中的目录
3) Python安装目录
(/usr/local/lib/python)
事实上,模块搜索是在保存在sys.path这个全局变量中的目录列表中进行搜索。
sys.path会在解释器开始执行时被初始化成包含:
1)当前工作目录
2) PYT ......

用 Python 3 写的命令行百度词典

今天是第二天自己看关于Python了,看见一个Python2写的百度词典,我也用Python 3 写了一个。真的很小巧,呵呵,很好的语言。
不知道怎么上传代码格式的,就上传文本了:
# -*- coding: utf8 -*-
import urllib.parse
import urllib.request
def search(word):
    #word = input("输入你要查询的 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号