ÓÃÕ»½âÎöËãÊõ±í´ïʽ[Python°æ]
´úÂëÖвÉÓÃÁËÈý²½ÊµÏÖËãÊõ±í´ïʽµÄ½âÎö:
1. ½«ËãÊõ±í´ïʽ(×Ö·û´®)ת»»³ÉÒ»¸öÁбíparseElement·½·¨
2. ½«Áбí±íʾµÄËãÊõ±í´ïʽת»»³Éºó׺±í´ïʽchangeToSuffix
3. ¼ÆËãºó׺±í´ïʽµÄ½á¹û
ÕâÀïÎÒÊÇΪÁË·½±ã, ¾ÍдÁ˸öparseElement, ²»ÏëÄÇ·½·¨Ð´µ½ºóÃæÈ´°Ñ×Ô¼ºÈÆסÁË, ¿ÉÒÔÏëÏóÒ»¸ö´ø×ÔÔö, λ, Âß¼, ËãÊõµÄ±í´ïʽµÄÊýÖµÌáÈ¡ÊǶàôµÄ¸´ÔÓ...
parseElement×Ô¼º¸Ð¾õÊÇÒ»¸ö±È½Ïʧ°ÜµÄ·½·¨, ËùÒÔ´ÓÒ»¸öÆÕ±éµÄ½Ç¶ÈÀ´·ÖÎöÒÔÏÂËãÊõ±í´ïʽµÄ½âÎö:
ÒÔ(A + B) * C / D ** E + F * GΪÀý
µÚÒ»²¿·Ö: ½«ÖÐ׺±í´ïʽ(ÉÏÃæ¾ÍÊÇ, ¾ßÌåÈ¥²éÓйØǰ׺, ÖÐ׺, ºó׺±í´ïʽ)
ÕâÒ»²½ÐèÒªÒ»¸öÕ»ÓÃÀ´±£´æÔËËã·û, Ò»¸ö×Ö·û´®ÓÃÀ´±£´æÊä³öµÄºó׺±í´ïʽ
·ûºÅÕ»: signStack
ºó׺±í´ïʽ: result
¹ý³Ì: ¶ÁÈ¡±í´ïʽÖÐÿ¸öÔªËØ(Êý×Ö»òÔËËã·û, ÎÒµÄparseElementÒâÔÚ½â¾öÕâ¸öÎÊÌâ, È´×öµÄ²»³É¹¦)
ÔÔò:
1. ²Ù×÷ÊýÖ±½ÓÊä³öµ½result
2. (Ö±½Ó½øÕ»
3. )³öÕ»Ö±µ½Óöµ½Ò»¸ö"("(×¢Òâ: ÕâÀï"("±ØÐë³öÕ»), Öмä³öÕ»µÄÔªËØ°´³öջ˳ÐòÊä³öµ½result
4. ÆäËûÔËËã·û, ¼ì²éÕ»¶¥ÔªËØ, Èç¹ûÕ»¶¥±Èµ±Ç°ÔËËã·ûÓÅÏȼ¶¸ß»òÏàͬ(ÓÅÏȼ¶Ïàͬ, °´Ë³ÐòÖ´ÐÐ)ÔòÏȽ«Õ»¶¥³öÕ», ÔÙÈëÕ». Èç¹ûµ±Ç°ÔªËØÓÅÏȼ¶¸ß, ÔòÖ±½ÓÈëÕ».
²Ù×÷¹ý³ÌµÄ״̬±ä»¯
signStack |result | current char
------------------------------------------------------
( | |(
( |A |A
(, + | |+
(  
Ïà¹ØÎĵµ£º
Ô´´úÂëÏÂÔØ£ºÏÂÔصØÖ·ÔÚÕâÀï
# 034
class Person:
def __init__(self, name):
self.name = name # ÕâÒ»¾äÖеÚÒ»¸önameÊÇÀàÖаüº¬µÄÓò£¬µÚ¶þ¸önameÊÇ´«½øÀ´µÄ²ÎÊý
# end of def
def sayHello(self):
print 'Hello!'
# end of def
# end of class
p = Person('Ning')
print p.nam ......
Ô´´úÂëÏÂÔØ£ºÏÂÔصØÖ·ÔÚÕâÀï
raiseÓÐÁ½¸ö²ÎÊý£¬µÚÒ»¸öÊÇÓÉÎÒÃÇ×Ô¼º¶¨ÒåµÄÒì³£ÀàÐÍ£¬µÚ¶þ¸öÊǹØÓÚ´ËÒì³£µÄÉÙÁ¿ËµÃ÷ÐÅÏ¢¡£
# 038
def getAge():
age = input('Input your age:')
if (age < 0 or age > 160):
raise 'BadAgeError', 'It is impossible!!!!!'
# end of if
return age
# ......
µÚ¾Å¹Ø Image
´ÓÒ³ÃæÉϵÄͼƬ¿ÉÒÔ¿´µ½ÓÐÒ»´®µã£¬ÄÇôÊDz»ÊÇ´ú±í¸Ã¹ØÓëͼÏñµãÓйأ¿ ÎÒÃÇ´ÓÒ³ÃæÔ´Âë¿ÉÒÔ¿´µ½£¬ÓÐÁ½¶ÎÊý×ÖÐòÁÐfirstºÍsecond£¬¶øÓÐÒ»¸öÌáʾfirst+second=? ʲôÒâ˼ÄØ£¿ÄѵÀÊÇ˵(first, second)´ú±íÁËͼÏñµãµÄ×ø±ê£¿²»Ïñ£¬Á½¶ÎÐòÁеij¤¶ÈÓкܴó²îÒì¡£ÄÇôËã·û+»¹ÓÐʲôº¬ÒåÄØ£¬Óп ......
ZoundryDocument
Python skin is known for its color variations and for its elasticity; it is
the warmest leather of the season and ideal for the manufacture of many luxury
goods. Sometimes natural patterns can be hidden when they're done in black, but
the finish here has a bit of a shine to it ......