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

python urllib2 ץȡÍøÒ³ ÈçºÎ²¶»ñ¸÷ÖÖÒì³£ÄØ

ÎÒÓÃpythonµÄ urllib2À´×¥È¡ÍøÒ³ Ôõô²ÅÄܲ¶»ñ¸÷ÖÖ·µ»ØµÄÒì³£ÄØ?
ÓÐÈçÏ´úÂë:
Python code:

import urllib2

if __name__ == '__main__':
url = 'http://hh'
try:
urllib2.urlopen(url, timeout=5)
except URLError, e:
print e.reason



ÎÒ²¶»ñÒì³£ È´ÌáʾÕâÖÖ´íÎó:
    except URLError, e:
NameError: name 'URLError' is not defined
ÊÇÔõô»ØÊ Ϊʲô˵ÎÒ䶨ÒåÄØ?
¸ÃÔõô¸Ä²Å¿ÉÒÔÄØ
»¹ÓÐ Âé·³¸æ֪һϠÍøÒ³¸÷ÖÖ·µ»Ø´íÎóÔõô²¶»ñÄØ
¿ÉÄÜÊÇûµ¼ÈëºÏÊʵĿâ
²»ÊÇÓиö¸üºÃµÄÀý×Óô
from urllib2 import Request, urlopen, URLError, HTTPError
req = Request(someurl)
try:
    response = urlopen(req)
except HTTPError, e:
    print 'The server couldn\'t fulfill the request.'
    print 'Error code: ', e.code
except URLError, e:
    print 'We failed to reach a server.'
    print 'Reason: ', e.reason
else:
    # everything is fine

ÒýÓÃ
ÎÒÓÃpythonµÄ urllib2À´×¥È¡ÍøÒ³ Ôõô²ÅÄܲ¶»ñ¸÷ÖÖ·µ»ØµÄÒì³£ÄØ?
ÓÐÈçÏ´úÂë:
Python codeimport urllib2if__name__=='__main__':
    url='http://hh'try:
       


Ïà¹ØÎÊ´ð£º

eric4ÔõôÔËÐÐpython³ÌÐò£¿

pythonºÍpyqtÒÔ¼°Eric4¶¼ÒѾ­ÅäÖúÃÁË£¬´ò¿ªEric4д¸öpython³ÌÐò±ÈÈç¼òµ¥µÄ
print¡°hello£¬world¡±£¬Ôõô±àÒëÔËÐÐÁË£¬Start²Ëµ¥µÄËùÓÐÃüÁ³öÏÖºÍͼÖв¶àµÄ¶Ô»°¿ò£¬Ó¦µ±ÔõôÔËÐÐÁË£¿

Çó´ó¼ÒÖ¸½Ì

ûÓÐÈËÓà ......

python½Ì³ÌÖÐʹÓÃÔ´ÎļþµÄÎÊÌâ~~

ʹÓÃÔ´Îļþ

#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'

ÎÒÔõôҲ¿´²»¶®£¡Ö»ÊÇ×îºóÒ»ÐÐÎÒÖªµÀ~~Ç°ÃæÁ½ÐÐÊÇʲôÒâ˼ÄØ£¿
½Ì³ÌÉÏ˵Èç¹ûÄãʹÓÃIDLE£¬ÇëʹÓò˵ ......

PythonÖеÄUnicodeÔÚDelphiÈçºÎ»¹Ô­³ÉGb2312£¿

ÒÑÖªPython ÖУº
s = unicode("²âÊÔ", "gb2312")
s = u'\u6d4b\u8bd5'
print s
²âÊÔ

ÔÚDelphiÀïÃæÈçºÎ½«\u6d4b\u8bd5ÕâÑùµÄ»¹Ô­³ÉGb2312µÄºº×ÖÄØ£¿
ÕÒµ½¸ö·½·¨
......

python 3.xµÄifÓï¾ä

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

>>> else:

SyntaxError: invalid syntax (<pyshell#20>, line 1)
ÍøÉÏËѵÄÒ²ÊÇ£º
>>> x=int(input("Please ent ......

°ÝʦÌù£ºÈçºÎʹÓÃpythonץȡÍøÒ³Êý¾Ý

ÈçºÎʹÓÃpython,½«ÏÂÃæµÄÍøÒ³
http://quotes.money.163.com/corp/1034/code=600221.html
ÄÇÕÅ×ʲú¸ºÕ®±íץȡ³öÀ´£¬·¢µ½Ò»¸öÎı¾ÎļþÖУ¿
ÇëÁôÏÂqq,ÎÒ°ÝÄãΪʦ


Python code:
import re
import url ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ