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

»°ËµPython£¨¶þ£©ÔçÀ´µÄÎļþ

»°ËµPython£¨¶þ£©
 
×Ô´ÓС°×ÉÏÍêµÚÒ»¿Î£¬Python¼òÖ±³ÉÁËËûµÄ¿Æѧ¼ÆËãÆ÷¡£Ã¿ÌìÔçÉÏ£¬Ð¡°××ÜÊDz»Íü“Á·Ï°”Ò»ÏÂPython¡£
 >>> 10000*1.2**40
14697715.679690843
“ºÙºÙ£¬ÎÒ·¢´ïÁË£¡”С°×ÔÚɵЦ×Å£¬ºÃÏñÔÚ×öÃΣ¬“ËÄÊ®Äêºó¾ÍÊÇÒÚÍò¸»ÎÌÀ²!”
 Ð¡²ËÇÃÁËÇÃС°×µÄÄÔ´ü£º“±ð˯ÁË£¬¸Ï½ôÈ¥ÉϿΡ£”
ÔËÐÐPython³ÌÐò£º
Python²»Í¬ÓÚC\C++µÈ±àÒëÐÍÓïÑÔ£¬²»ÐèÒª±àÒë³É¿ÉÖ´ÐÐÎļþ¡£½âÊÍÐÔµÄÓïÑÔ£¬¹ËÃû˼Ò壬ÊÇÓɽâÊÍÆ÷Ö±½Ó¶ÁÈ¡Ô´ÎļþÔËÐС£
н¨Ò»¸ö¼Çʱ¾£¬È»ºó´ò¿ªËüÊäÈë
print("hello world!")
±£´æ²¢¹Ø±Õ£¬½«¼Çʱ¾ÎļþÖØÃüÃûΪhello.py¡£Õâʱºò£¬Äã»á·¢ÏÖÎļþµÄͼ±ê±ä³ÉÀàËÆÓÚPython ShellµÄÑù×ÓÁË¡££¨Èç¹ûû±ä»¯£¬ËµÃ÷ÄúûÓа²×°Python£¬»òÕßÎļþºó׺²»ÊÇ.py£©
Ë«»÷¾Í»áÔËÐÐËü£¬ÊDz»ÊǺܼòµ¥°¡£¡
“ɶҲûÓа¡£¡Ð¡²Ì£¬¸ø¸ç¿´¿´£¡”С°×¶¢×ÅÆÁÄ»£¬Ê¹¾¢µã×Åhello.py¡£
“ÎÒ˵С°×°¡£¬ÄãѧµÄCÓïÑÔ¶¼½»¸øÀÏʦÁË£¿”С²ËºÜÎÞÄΡ£
»¹¼ÇµÃ¿ªÊ¼Ñ§CÓïÑÔµÄʱºòÂð£¿ÏÖÔÚÎÒÃǵÄPython³ÌÐòÏÖÔÚ»¹Ã»ÓпÉÊÓ»¯µÄ½çÃæ¡£print()º¯ÊýÆäʵÊǽ«×Ö·û´®Êä³öµ½¿ØÖÆ̨£¬ÎÒÃÇ¿´²»µ½µÄÔ­ÒòÊÇÒòΪËüÖ´ÐеÄÌ«¿ìÁË£¬ÒÔÖÁÓÚÎÒÃÇÒÔΪËüûÓÐÔËÐС£
ÓÒ»÷hello.py£¬´ò¿ª·½Ê½Ñ¡¼Çʱ¾¡£½«ÄÚÈݸÄΪ
import os #ÒýÈëosÄ£¿é
print("hello world!")
os.system("pause") #µ÷ÓÃosÄ£¿éµÄº¯Êýsystem()ÔÝÍ£³ÌÐò
  
½âÊÍһϣºµÚÒ»ÐÐimport ±íʾÒýÈëÄ£¿é£¬ÕâÀïÒýÈëµÄÊÇosÄ£¿é£»µÚÈýÐе÷ÓÃosÄ£¿éµÄsystem()º¯Êý£¬²ÎÊýÊÇ"pause" ,±íʾÔÝÍ£¡£ÏÖÔÚÔËÐÐһϿ´¿´£¬ÔõôÑù£¿
Python¿ìËÙÉÏÊÖ
PythonµÄ×éÖ¯ÐÎʽ£º
Python×î»ù±¾µÄ½á¹¹ÈÝÆ÷¾ÍÊÇÄ£¿é£¬¸Õ²ÅµÄhello.pyÎļþ´ÓÂß¼­ÉÏ˵¾ÍÊÇÒ»¸öÄ£¿é¡£µ±È»£¬Ò»¸öÄ£¿é¿ÉÒÔÈÏΪ¾ÍÊÇÒ»¸öÎïÀíÉϵÄÎļþ¡£
ÃæÏò¶ÔÏóÖÐ×îÖØÒªµÄ¸ÅÄî¾ÍÊÇÀ࣬¼òµ¥À´Ëµ£¬ÀàÊÇ°ü×°·½·¨ºÍ±äÁ¿µÄ£¬Ìṩµ÷ÓõĽӿڡ£×¢ÒâÀàºÍÄ£¿éµÄ²»Í¬£ºÀàÊÇ·½·¨ºÍ±äÁ¿µÄ¼¯ºÏ£¬¶øÄ£¿éµÄ×÷Óýö½öÆðµ½ÃüÃû¿Õ¼äµÄ×÷Óá£
ÔÚ´´½¨ÐíÐí¶àÄ£¿éºó£¬ÎÒÃÇ¿ÉÄÜÏ£Íû½«Ä³Ð©¹¦ÄÜÏà½üµÄÎļþ×éÖ¯ÔÚͬһÎļþ¼ÐÏ£¬ÐγÉÒ»¸ö°ü¡£µ±Îļþ¼Ðµ±×÷°üʹÓÃʱ£¬Îļþ¼ÐÐèÒª°üº¬__init__.pyÎļþ£¬ÓÃÓÚÃèÊö°üµÄÄ£¿éÐÅÏ¢¡£
×¢Ò⣺³õѧÕßÍùÍùÈÏΪÔÚPython ShellÖÐʹÓÃPython *.py ÔËÐгÌÐò£¬ÕâÊÇÈÏʶÉϵĴíÎó£¬Python ShellÊÇÒ»¸öÓï¾äÖ´Ðл·¾³£¬²¢²»ÊÇÖ´ÐÐÖնˡ£ÊÂʵÉÏ£¬ÕýÈ·µÄ·½·¨ÊÇÔÚcmdÖÐÔËÐУ¨×¢ÒâÉèÖû·¾³±


Ïà¹ØÎĵµ£º

pythonµÄÒì³£Exception


Python µÄÒì³£´¦Àí»úÖÆ
Python´úÂë 
 try:    
  raise Exception("a", "b")    
    except Exception,e:    
  print e    
    finally:    
  print "final"    
('a', ......

»°ËµPython£¨Ò»£©

С°×ºÍС²ËÊÇ´óѧͬѧ£¬Õâ²»¿ìÒª±ÏÒµÁË£¬Á©ÈËÒ»ºÏ¼Æ£¬ÕÒ¸öÅàѵ°àѧµã¶«Î÷£¬Îä×°Ò»ÏÂÍ·ÄÔ£¬Ë³±ã½â¾ö¾ÍÒµÎÊÌâ¡£
“ÄãÃÇÒª±¨Äĸö°à°¡£¿”½Ó´ýËûÃǵÄÄêÇáС½ãÈÈÐĵØÎʵÀ¡£
“ÄãÃÇÕâÀïÄĸö°à×îºÃ£¿”С°×²»¼Ù˼Ë÷µØ˵£¬“µ±È»ÊDZ¨×îºÃµÄ°àÀ²¡£”
“ÎÒÃǹ«Ë¾µÄÅàѵÏîÄ¿¶¼ºÜºÃ”С½ãЦ ......

PythonͨѶ²¾

ÕâÁ½ÌìÔÚѧϰpythonÓïÑÔ£¬Ò²Ñ§×ÅдÁ˸öͨѶ²¾£¬Á·Ï°ÈëÃÅÏ£¡
¹¦ÄÜ°üÀ¨ÒÔÏ£º
1¡¢Ôö¼ÓÒ»Ìõ¼Ç¼
2¡¢É¾³ýÒ»Ìõ¼Ç¼
3¡¢ÐÞ¸ÄÒ»Ìõ¼Ç¼
4¡¢²éѯһÌõ¼Ç¼
5¡¢ÏÔʾÕû¸öͨѶ²¾
6¡¢°ïÖúÌáʾ
7¡¢°æ±¾ÏÔʾ
8¡¢Í˳öµÈ
Ê×ÏȽ¨Á¢Ò»¸öPersonÀ࣬¼´Person.pyÎļþ£¬ÓÃÀ´±£´æÁªÏµÈ˼Ǽ£º
class Person:
def __init__(self, nam ......

[Ô­´´]PythonÄÚ´æй©²é¿´Æ÷ʵÏÖ

[Ô­´´]PythonÄÚ´æй©²é¿´Æ÷ʵÏÖ
by AKara 2009-04-23 @ http://blog.csdn.net/akara @ akaras@163.com
   
---------------------------------------------------------------------
  Ϊ¸üºÃ¶¨Î»PythonÄÚ´æй©Çé¿ö£¬Ð´ÁËÒ»¸öеÄPythonÄÚ´æй©²é¿´Æ÷Ä£¿é¡£
Ä£¿éÓÐÈçϹ¦ÄÜ£º
  * ½«ËùÓ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ