try:
seq = int(seq)
if seq < 0:
print "Error"
except (TypeError, ValueError):
print "Error"
ÔÚÕâÀïÎÒÏë°Ñ seq Ö»ÒªÊDz»´óÓÚµÈÓÚ0µÄ¶¼Å×Òì³£ ¿ÉÒÔÂð£¿
ÁíÍâassert Å׳öµÄÒì³£ except ºÃÏñ½Ø»ñ²»µ½°¡
except ºóÃæ²»Òª¼ÓÀ¨ºÅ.
......
feedparserµ¼ÈëÕâ¸ö°ü ¶ÁxmlµÄtitle£¬link ¶¼Ã»ÎÊÌâ ¾ÍÊÇʱ¼ä¶ÁÈ¡²»³öÀ´
´íÎó£º
print d['feed']['%s lastBuildDate']
return UserDict.__getitem__(self, realkey)
KeyError: '%s lastBuildDate'
Õâ¸öÊÇÔõô»ØÊ Ôõô ´¦Àí
'%s lastBuildDate'Óï·¨ÉÏÓÐÎÊÌâ°É... ......
ÎÒÏÖÔÚÒªÓÃpython·ÃÎÊÒ»¸öÍøÕ¾µÄÍøÒ³£¬È¡µÃһЩÐÅÏ¢
µ«ÊÇÍøÕ¾ÒªÇóÏȵǼ£¬È»ºó²ÅÄܼÌÐø·ÃÎÊ£¬µÇ¼¹ý³Ì¾ÍÊÇдÁ˸öcookie
ÇëÎÊÏÂpython·ÃÎÊÍøÒ³Ôõô±£³ÖסcookieÄØ£¿
ÎÒÓõÄÊÇpython3.1£¬Ö»ÓÐurllibºÍhttpÁ½¸ö¿âÁË
ÍøÉÏÕÒÁËһЩ´úÂ룬¶¼ÊÇpython2.x°æ±¾µÄ
ÄÄλºÃÐĵÄÐÖµÜд¼¸¾äpython3.1µÄ´úÂ룬¸Ð¼¤² ......
ÓÐÒ»¸öÎı¾ 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 ......
>>> 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ºËÐıà³Ì¡·ÕâÊéµÄµÚÒ»°æ»¹ÊDz»´íµÄ£¬µÚ¶þ°æºÜ²»Õ¦µÄ£¬ÕæµÄ¡£
¸öÈ˵ÄÒâ¼ûÊÇ£º³õѧÓá¶Dive in Python¡·£¬ÕâÊéûÖÐÎÄ°æ³ö°æ£¬µ«ÍøÉÏÓÐÖÐÎÄ°æµÄµç×ÓÊé¡£
ÎÒµ¹¾õµÃDive in pythonÊÇÓеãPython»ù´¡µÄÈË¿´µÄ ......