¹ØÓÚ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)
Ïà¹ØÎĵµ£º
refer from: http://www.daniweb.com/forums/thread115282.html#
python
Syntax
(Toggle Plain Text
)
# respond to a key
without the need to press
enter
import
Tkinter
as tk
def
keypress(
event)
:
if
event.keysym
== 'Escape'
:
root.destroy
......
ubuntu10.05³öÀ´ÁËÕâÁ½ÌìÒ»Ö±ÔÚÕÛÌÚ£¬ÏÔʾwubiÎÞ·´Ó¦£¬È»ºó´ÓÓ²Å̰²×°ÆÚ¼äÓÖÓöµ½grub´íÎóµÈÎÊÌâ¡£°²×°³É¹¦ºó¸ã¸öÖÐÎÄÊäÈë·¨¾ÍÀϰëÌ죬×îºóʹÓÃPinyinÕâ¸ö»¹ËãºÃÓã¬ÓеãÏëËѹ·¾ÍÊÇûʲô´Ê¿â¡£×î¶ñÐĵϹÊÇvimµÄÎÊÌ⣬ÓÃapt-get install vim×°µÄvim²»Ö§³Öϵͳ¼ôÇа壬ֻºÃ´ÓÔ´´úÂë±àÒ룬¿ÉÊÇÎÒ³¢ÊÔÁ˺ܶà´Î×ÜÊÇûÓÐpythonÖ§ ......
½ñÌìÊǵڶþÌì×Ô¼º¿´¹ØÓÚPythonÁË£¬¿´¼ûÒ»¸öPython2дµÄ°Ù¶È´Êµä£¬ÎÒÒ²ÓÃPython 3 дÁËÒ»¸ö¡£ÕæµÄºÜСÇÉ£¬ºÇºÇ£¬ºÜºÃµÄÓïÑÔ¡£
²»ÖªµÀÔõôÉÏ´«´úÂë¸ñʽµÄ£¬¾ÍÉÏ´«Îı¾ÁË£º
# -*- coding: utf8 -*-
import urllib.parse
import urllib.request
def search(word):
#word = input("ÊäÈëÄãÒª²éѯµÄ ......
»ù±¾É϶¼ÊÇʹÓÃpythonÀ´½âÎöxmlÎļþµÄ¡£
±ÈÈçÎÒÒª½«ÄÚÈÝΪ
<?xml version="1.0" encoding="utf-8"?>
<root>
<book isbn="34909023">
<author>
&n ......
ÔÚLearning Python 3rd ÀïµÚÈý²¿·ÖÁ·Ï°ÌâÓеÀÌ⣺
1.c ±àдfor Ñ»·£¬¶ÔÓÚ×Ö·û´®S£¬·µ»ØÒ»¸öеÄÁÐ±í£¬ÆäÖаüº¬ÁË×Ö·û´®Ã¿¸ö×Ö·ûµÄASCIIÂë¡£
ÎÒµÄ˼·ÊÇ£º
for i in S:
L = [ord(i) for i in S] #Áбí½âÎöµÄ˼·
ÎҵĴíÎó˼·£º
for i in S:
L = L.append(ord(i))
Ìáʾ¿Õ¶ ......