Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python 2.4Óë2.5ÖÐ×Ö·û´®Óëdatetimeת»»µÄÇø±ð

python 2.4ÖÐdatetimeÓÐstrftime·½·¨¶øÎÞstrptime·½·¨
¶øpython2.5ÖÐÕâÁ½¸ö·½·¨¾ùÓУ¬¶øÎҵĿª·¢»·¾³ÕýºÃÊÇpython 2.5£¬¶øÔËÐл·¾³ÔòÊÇpython 2.4
¿ª·¢»·¾³Ïµ÷ÊԺõijÌÐò£¬ÔÚ·þÎñÆ÷ÉϾͲ»run¡£²éÁËÒ»ÏÂpythonµÄ¹Ù·½Îĵµ
£¬Ð±Ìåд×Å£ºNew
in version 2.5.
²»¼æÈݵĴúÂëÈçÏ£º
PythonÓïÑÔ
:
test_strptime.py
resulttime =
datetime.datetime.strptime(timepoint, '%Y-%m-
%d
'
) #Õâ¿ÉÊÇpydev×Ô¶¯µ¯³öÀ´µÄ·½·¨
Ôõô¸ÄÏÂÈÃËüÔÚ2.4ÏÂÒ²ÄÜÅÜÄØ£¿googleÏ£¬
µÃ´ð°¸ÈçÏ£º
t = time.strptime(timepoint, '%Y-%m-%d')
resulttime = datetime.datetime(*t[:6])
Áí£º¸½×ªÒå·û¶ÔÓ¦ÒâÒåÈçÏÂ
%a ±¾µØ¼ò»¯ÐÇÆÚÃû³Æ
%A ±¾µØÍêÕûÐÇÆÚÃû³Æ
%b ±¾µØ¼ò»¯µÄÔ·ÝÃû³Æ
%B ±¾µØÍêÕûµÄÔ·ÝÃû³Æ
%c ±¾µØÏàÓ¦µÄÈÕÆÚ±íʾºÍʱ¼ä±íʾ
%d ÔÂÄÚÖеÄÒ»Ì죨0-31£©
%H 24СʱÖÆСʱÊý£¨0-23£©
%I 12СʱÖÆСʱÊý£¨01-12£©
%j ÄêÄÚµÄÒ»Ì죨001-366£©
%m Ô·ݣ¨01-12£©
%M ·ÖÖÓÊý£¨00=59£©
%p ±¾µØA.M.»òP.M.µÄµÈ¼Û·û
%S Ã루00-59£©
%U Ò»ÄêÖеÄÐÇÆÚÊý£¨00-53£©ÐÇÆÚÌìΪÐÇÆڵĿªÊ¼
%w ÐÇÆÚ£¨0-6£©£¬ÐÇÆÚÌìΪÐÇÆڵĿªÊ¼
%W Ò»ÄêÖеÄÐÇÆÚÊý£¨00-53£©ÐÇÆÚһΪÐÇÆڵĿªÊ¼
%x ±¾µØÏàÓ¦µÄÈÕÆÚ±íʾ
%X ±¾µØÏàÓ¦µÄʱ¼ä±íʾ
%y Á½Î»ÊýµÄÄê·Ý±íʾ£¨00-99£©
%Y ËÄλÊýµÄÄê·Ý±íʾ£¨000-9999£©
%Z µ±Ç°Ê±ÇøµÄÃû³Æ
%% %ºÅ±¾Éí


Ïà¹ØÎĵµ£º

python ÃüÁîÐвÎÊý


±¾Æª½«½éÉÜpythonÖÐsys, getoptÄ£¿é´¦ÀíÃüÁîÐвÎÊý
Èç¹ûÏë¶Ôpython½Å±¾´«²ÎÊý£¬pythonÖжÔÓ¦µÄargc, argv(cÓïÑÔµÄÃüÁîÐвÎÊý)ÊÇʲôÄØ£¿
ÐèҪģ¿é£ºsys
²ÎÊý¸öÊý£ºlen(sys.argv)
½Å±¾Ãû£º    sys.argv[0]
²ÎÊý1£º     sys.argv[1]
²ÎÊý2£º     sys.argv[2]
test.py
1
import ......

PythonµÄbug

PythonÌ«»ðÁË£¬²»Ñ§µã¶¼¸Ð¾õ×Ô¼º²»ÊÇѧ¼ÆËã»úµÄ£¬½ñÌì¿´Á˸ö²»´íµÄ¡¶¼òÃ÷python½Ì³Ì¡·£¬ºÜ²»´í¡£²»¹ýÔÚѧϰ¹ý³ÌÖУ¬¾ÓÈ»·¢ÏÖÁËÒ»¸öPythonµÄbug£¬
#!/usr/bin/python
#coding=UTF-8
class Person:
'''Represents a person.'''
population = 0
def __init__(self, name):
'''Initializes the person's data.'''
......

Python´úÂë¼ÓÃÜ Ô´Âë±£»¤ pycÎļþ'×Ö½ÚÂë'

from   http://blog.alexa-pro.cn/?p=349
ÄÚÈݸÅÒª:Python´úÂë¼ÓÃÜ,Ô´Âë±£»¤,´úÂë±£»¤,pycÎļþ
------------------------------------------------
¹ØÓÚpython´úÂë±£»¤ÔÚÍøÉϺÃÏñһֱûÓкܺõĽéÉÜ,¿ÉÄܺÍPYTHONµÄÉè¼Æ³õÖÔ"¿ªÔ´"ÓйØ,µ«Ô½À´Ô½¶àµÄÐÖµÜдµÄ¼ÓÈëPYTHONÕóÓª,¿ª·¢¹¤¾ßÓÃ;¸÷Òì,ÔÚÉÌÒµÓ¦ÓÃÖдúÂë± ......

¶ÔPython½ø³Ì½øÐÐÈ«½âÎö

ÏÂÃæ¶ÔPython½ø³Ì½øÐÐÉîÈë¶ø×ÐϸµÄѧϰ£¬Ê×ÏÈÏÈÈôó¼ÒÁ˽âÏÂʲôÊÇPython½ø³Ì£¬ÒÔ¼°ÔÚ¶ÔPython½ø³Ì½øÐд¦ÀíʱעÒâµÄÏà¹ØÎÊÌ⣬½ÓÏÂÀ´£¬¾ÍÓÉÎÒ¸ø´ó¼Ò½øÐнéÉÜѧϰ£¬½ö¹©´ó¼Òѧϰ¡£
²»¹ý£¬ËäÈ»½ø³Ì¿ÉÔÚµ¥¶ÀµÄÄÚ´æ¿Õ¼äÖÐÖ´ÐУ¬µ«³ý·ÇÕâЩPython½ø³ÌÔÚµ¥¶ÀµÄ´¦ÀíÆ÷ÉÏÖ´ÐУ¬·ñÔò£¬Êµ¼Ê²¢²»ÊǓͬʱ”ÔËÐеġ£ÊÇÓɲÙ×÷ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ