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

PythonÈëÃŵÄ36¸öÀý×Ó Ö® 29

Ô´´úÂëÏÂÔØ£ºÏÂÔصØÖ·ÔÚÕâÀï
# 033
class Person:
age = 22
def sayHello(self): # ·½·¨Ó뺯ÊýµÄÇø±ðÔÚÓÚÐèÒªÒ»¸öself²ÎÊý
print 'Hello!'
# end of def
# end of class # ÕâÊÇÎÒÁ¼ºÃµÄ±à³Ì·ç¸ñ
p = Person()
print p.age
p.sayHello()

output£º
22
Hello!


Ïà¹ØÎĵµ£º

pythonÔËËã·û ¹©ÖØÔزο¼

¶þÔªÔËËã·û¼°Æä¶ÔÓ¦µÄÌØÊâ·½·¨
¶þÔªÔËËã·û
ÌØÊâ·½·¨
+
__add__,__radd__
-
__sub__,__rsub__
*
__mul__,__rmul__
/
__div__,__rdiv__,__truediv__,__rtruediv__
//
__floordiv__,__rfloordiv__
%
__mod__,__rmod__
**
__pow__,__rpow__
<<
__lshift__,__rlshift__
>>
_ ......

PythonÄ£¿éѧϰ

¡¡¡¡ÓÐʱºò£¬Òª°ÑÄÚ´æÖеÄÒ»¸ö¶ÔÏó³Ö¾Ã»¯±£´æµ½´ÅÅÌÉÏ£¬»òÕßÐòÁл¯³É¶þ½øÖÆÁ÷ͨ¹ýÍøÂç·¢Ë͵½Ô¶³ÌÖ÷»úÉÏ¡£PythonÖÐÓкܶàÄ£¿éÌṩÁËÐòÁл¯Óë·´ÐòÁл¯µÄ¹¦ÄÜ£¬È磺marshal, pickle, cPickleµÈµÈ¡£½ñÌì¾Í½²½²marshalÄ£¿é¡£
¡¡¡¡×¢Ò⣺
marshal²¢²»ÊÇÒ»¸öͨÓõÄÄ£¿é£¬ÔÚijЩʱºòËüÊÇÒ»¸ö²»±»ÍƼöʹÓõÄÄ£¿é£¬ÒòΪʹÓÃmarshalÐ ......

PythonÈëÃŵÄ36¸öÀý×Ó Ö® 19

Ô´´úÂëÏÂÔØ£ºÏÂÔصØÖ·ÔÚÕâÀï
# 022
listNum1 = [1, 3]
listNum2 = [2, 4]
listStr1 = ['a', 'c']
listStr2 = ['b', 'd']
# ÁбíµÄºÏ²¢
list1 = listNum1 + listStr1
for ele in list1:
print ele
print '\n'
# ÅжÏÁбíÖÐÊÇ·ñ°üº¬Ä³ÔªËØ
print 'b' in list1
print 1 in list1
# ɾ³ýij¸öÔªËØ
for ele in ......

PythonÈëÃŵÄ36¸öÀý×Ó Ö® 27

Ô´´úÂëÏÂÔØ£ºÏÂÔصØÖ·ÔÚÕâÀï
e.g.1
# 030
aFile = file(r'C:\temp.txt', 'a')
aFile.write('ÓÖÌí¼ÓÁËÒ»ÐС£')
aFile.close()

output:
e.g.2
# 030
aFile = file(r'C:\temp.txt', 'a')
aFile.write('ÓÖÌí¼ÓÁËÒ»ÐС£')
aFile.close()

output:
e.g.3
ʵÏÖ¸ù¾ÝԭʼÎļþÓÐûÓÐ×îºóÒ»ÐпÕÐеÄÇé¿öÀ´½øÐÐ&ldqu ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ