Python¼òÒ׹ɯ±²éѯ(ץȡgoogle²Æ¾µÄÄÚÈÝ)
¿´×ÅÍøÉÏ×¥È¡ÍøÒ³Êý¾ÝµÄÎÄÕÂÖ±µÉÑÛ
ºóÀ´Ïëµ½ÓÃ×Ö·û´®·Ö¸îÀ´ÌáÈ¡ÏàÓ¦²¿·ÖµÄÄÚÈÝ
³ÌÐò¼òµ¥£¬µ«ÊýÐÐÊýºÍϱê·ÑÁ˺ܳ¤Ê±¼ä
ÎÒÖªµÀÕâ¿Ï¶¨²»ÊÇ×îºÃµÄ°ì·¨- -!!
µ«ÎÒʵÏÖÁË£¬¹þ¹þ
# -*- coding: cp936 -*-
from urllib import *
import re
def stockSearch():
baseurl="http://www.google.cn/finance?q=SHA%3A"
stockNo=raw_input("ÇëÊäÈë¹ÉƱ´úÂë:")
fullUrl=baseurl+stockNo
#print fullUrl
stockPage=urlopen(fullUrl)
pageInfo=stockPage.readlines()
stockNameLine=pageInfo[4]
stockNameList=re.split('[ >]',stockNameLine)
print "ÄúËù²éѯµÄ¹ÉƱÊÇ:"+stockNameList[1]
stockInfoLine=pageInfo[184]
stockInfoList=re.split('values',stockInfoLine)
stockInfoDetail=re.split('"',stockInfoList[1])
print "ÏÖ¼Û£º"+stockInfoDetail[3]
print "ÕÇ·ù: "+stockInfoDetail[5]+"%"
print "ÿ¹ÉÊÕÒæ: "+stockInfoDetail[9]
print "ÊÐÖµ: "+stockInfoDetail[11]
chengJiaoLiang=re.split('[><]',pageInfo[248])
print "³É½»Á¿: "+chengJiaoLiang[2]
while True:
stockSearch()
Ïà¹ØÎĵµ£º
¹«Ë¾µÄ´úÀí¿ÉÒÔÖ±½Ó´©Ç½£¬×ÔÓÉ·ÃÎÊTwitter¡¢FacebookµÈÍøÕ¾£¬ÕâÁ½ÌìÑо¿ÁËÒ»ÏÂTwitterÌṩµÄAPI£¬ÓÃpythonдÁËÒ»¸ötwitter client£¬Ö»ÊµÏÖÁË»ù±¾¹¦ÄÜ£¬²é¿´×Ô¼ºµÄtwitterÏûÏ¢£¬Ò²¿ÉÒÔ²»ÑéÖ¤£¬²é¿´publicµÄtwitterÏûÏ¢¡£ÆäËû¹¦ÄÜʵÏÖÀàËÆ¡£Ö÷Òªº¯ÊýÈçÏ£º
def fetch_with_proxy(proxy, username, password, url):
&n ......
pythonÖÐÀàµÄÊôÐÔ
pythonÖеÄÀà½Ðclass object,ÀàµÄʵÀý½Ðinstance object.
Àà Class Objects
ÀàÓµÓÐÁ½ÖÖ²Ù×÷,1.ÀàÊôÐÔ attribute references 2.ʵÀý»¯instantiation
1.ÀàÊôÐÔ¾ÍÏ൱ÓÚרÊôÓÚÒ»¸öÀàµÄ±äÁ¿(¼´Ä³Ð©ÓïÑÔÖеÄÀàµÄ¾²Ì¬¹«¹²±äÁ¿static public),ʹÓ÷½·¨ÊÇ:ÀàÃû³Æ.ÀàÊôÐÔÃû³Æ
2.ʵÀý»¯ÔòÊÇ´´½¨Ò»¸öÀàµÄʵÀýµÄ· ......
Python¿ìËÙÈëÃÅ
Ŀ¼
1. µÚÒ»Õ Python¿ìËÙÈëÃÅ
&nbs ......
PythonÖ§³Öascii×Ö·û´®£¬unicode×Ö·û´®£¬ÒÔ¼°¸÷ÖÖ×Ö·û¼¯£¬ÄÇôËüÃǵ½µ×¸÷ÊÇʲô¸ÅÄÏ໥֮¼ä´æÔÚºÎÖÖ¹ØÏµÄØ£¿
ÔÚPythonÖУ¬ascii×Ö·û´®£¬¼´strÀàÐ͵ÄÖµ£¬¿ÉÄÜÓÃÀ´±íʾÈÎÒâµÄÒ»¿é´æ´¢¿Õ¼ä£¬ÄÇôҲ¾ÍÊÇ˵£¬Õâ¸ö×Ö·û´®ÄÚ²¿¿ÉÒÔÊÇÈκÎÖµ£¬ÀýÈ磺¿É¼û×Ö·û×é³ÉµÄ×Ö·û´®£¬»òÕßÒ»¶Î¶þ½øÖÆÊý¾ÝµÈ¡£unicode×Ö·û´®£¬¼´unicodeÀàÐ굀 ......
1.1. Óï·¨
1.1.1. if
>>> x=int(raw_input("please enter an integer:"))
please enter an integer:-8
>>> if x<0:
... print 'negative'
... elif x==0:
... print 'zero'
... else:
... print 'positive'
...
negative
ÕâÀïÓм¸¸ö֪ʶµãÐèÒªÌáÐÑ£º
1¡£ºÍ ......