Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : Python

python try catch

try:
  seq = int(seq)
  if seq < 0:
    print "Error"
except (TypeError, ValueError):
  print "Error"

ÔÚÕâÀïÎÒÏë°Ñ seq Ö»ÒªÊDz»´óÓÚµÈÓÚ0µÄ¶¼Å×Òì³£ ¿ÉÒÔÂð£¿
ÁíÍâassert Å׳öµÄÒì³£ except ºÃÏñ½Ø»ñ²»µ½°¡
except ºóÃæ²»Òª¼ÓÀ¨ºÅ.
......

python¸ù¾Ýfeedparser¶ÁÈ¡xmlµÄʱ¼ä

feedparserµ¼ÈëÕâ¸ö°ü ¶ÁxmlµÄtitle£¬link ¶¼Ã»ÎÊÌâ ¾ÍÊÇʱ¼ä¶ÁÈ¡²»³öÀ´
´íÎó£º
print d['feed']['%s lastBuildDate']

return UserDict.__getitem__(self, realkey)
KeyError: '%s lastBuildDate'

Õâ¸öÊÇÔõô»ØÊ Ôõô ´¦Àí
'%s lastBuildDate'Óï·¨ÉÏÓÐÎÊÌâ°É... ......

python·ÃÎÊÍøÒ³´øcookieÎÊÌâ

ÎÒÏÖÔÚÒªÓÃpython·ÃÎÊÒ»¸öÍøÕ¾µÄÍøÒ³£¬È¡µÃһЩÐÅÏ¢
µ«ÊÇÍøÕ¾ÒªÇóÏȵǼ£¬È»ºó²ÅÄܼÌÐø·ÃÎÊ£¬µÇ¼¹ý³Ì¾ÍÊÇдÁ˸öcookie
ÇëÎÊÏÂpython·ÃÎÊÍøÒ³Ôõô±£³ÖסcookieÄØ£¿

ÎÒÓõÄÊÇpython3.1£¬Ö»ÓÐurllibºÍhttpÁ½¸ö¿âÁË
ÍøÉÏÕÒÁËһЩ´úÂ룬¶¼ÊÇpython2.x°æ±¾µÄ

ÄÄλºÃÐĵÄÐÖµÜд¼¸¾äpython3.1µÄ´úÂ룬¸Ð¼¤² ......

python¶ÁÎı¾Êý¾Ý

ÓÐÒ»¸öÎı¾ test.txt  Àï±ßÈ«ÊÇÊý¾Ý£¬ÅÅÁиñʽ»¯ÈçÏ£º

1 2 3
4 5 6
7 8 9

ÔõôÓÃpython¶ÁÈ¡¸ÃÎı¾²¢½«Ã¿ÐÐÈý¸öÊý×ÖÏà¼Ó£¬×îºóÒÔÎı¾ out.txt Êä³ö½á¹û£¬±ÈÈ磺
1+2+3=6
4+5+6=15

-------
ÎÒ×Ô¼º¹¹½¨ÁËÒ»¸öº¯Êý def sum(a,b,c): return a+b+c
Ïë¶ÁÈ¡Ò»ÐÐÊý¾Ý·Ö±ð¸³¸øa£¬b£¬c&n ......

python 3.xµÄifÓï¾ä

>>> x=-1
>>> if x>0:
print ('11')

>>> else:

SyntaxError: invalid syntax (<pyshell#20>, line 1)
ÍøÉÏËѵÄÒ²ÊÇ£º
>>> x=int(input("Please enter an integer:"))
Please enter an integer:23
>>> if x<0:
x=0
print("zero ......

¿ªÊ¼Ñ§Ï°python, ´ó¼Ò¶à¶àÖ¸µã

¸Õ¸ÕÂòÁËÒ»±¾¡¶PythonºËÐıà³Ì¡·£¬¿ªÊ¼Ñ§Ï°python¡£´ó¼Ò¶à¶àÖ¸½Ì

µç×ÓÊé¾ÍºÜ¶à¡£¡£¡£

¡¶PythonºËÐıà³Ì¡·ÕâÊéµÄµÚÒ»°æ»¹ÊDz»´íµÄ£¬µÚ¶þ°æºÜ²»Õ¦µÄ£¬ÕæµÄ¡£

¸öÈ˵ÄÒâ¼ûÊÇ£º³õѧÓá¶Dive in Python¡·£¬ÕâÊéûÖÐÎÄ°æ³ö°æ£¬µ«ÍøÉÏÓÐÖÐÎÄ°æµÄµç×ÓÊé¡£



ÎÒµ¹¾õµÃDive in pythonÊÇÓеãPython»ù´¡µÄÈË¿´µÄ ......
×ܼǼÊý:175; ×ÜÒ³Êý:30; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [9] [10] [11] [12] 13 [14] [15] [16] [17] [18]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ