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

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

Ô´´úÂëÏÂÔØ£ºÏÂÔØµØÖ·ÔÚÕâÀï
# 024
dict1 = {
'5064001':'Mememe',
'5064002':'tutu',
'5064003':'thrthr',
'5064004':'fofo'
}
print dict1['5064003']
# Ò²¿ÉÒÔʹÓÃÕûÐÍ×÷ΪΨһµÄ±àºÅ
dict2 = {
5064001:'Mememe',
5064002:'tutu',
5064003:'thrthr',
5064004:'fofo'
}
print dict2[5064003]
# Ìí¼Ó
dict2[5064000] = 'none'
print dict2[5064000]
del dict2[5064002]
print dict2
for ele in dict2:
print ele
for id, name in dict2.items():
print id, name

output£º
thrthr
thrthr
none
{5064000: 'none', 5064001: 'Mememe', 5064003: 'thrthr', 5064004: 'fofo'}
5064000
5064001
5064003
5064004
5064000 none
5064001 Mememe
5064003 thrthr
5064004 fofo


Ïà¹ØÎĵµ£º

pythonÖÐʹÓ÷½±ãµÄLIST¶ÔÏó

×î½ü¶Ôpython²úÉúÁËÐËȤ£¬ÓÚÊÇ´ÓÍøÉÏÏÂÔØÁË»ù±¾PYTHONµÄÊéºÍÎĵµ£¬¿ªÊ¼ÁËPYTHONµÄѧϰ£¬·¢ÏÖPYTHONÖеÄlist¶ÔÏóµÄ¹¦ÄÜʵÔÚÊǷdz£Ç¿´ó£¬±à³ÌÆðÀ´±ÈÆäËûµÄ³ÌÐòÓïÑÔ¶ÔÁбíµÄ²Ù×÷Òª·½±ãµÄ¶à¡£
ÔÚpythonÖж¨ÒåÒ»¸öÁбíÖ»ÐèÒªÈçÏÂÓï¾ä
li = ["a","b","c","d"]
listÓÐÐí¶àµÄº¯Êý¿ÉÒÔÓÃÀ´½øÐжÔÁбíµÄ²Ù×÷£¬Èçextend,append,inse ......

×î¼òµ¥µÄ python ¶àÏß³ÌʾÀý

import time,thread
def test(a,b):
for i in range(a,b):
       time.sleep(1)
       print i
def start():
thread.start_new_thread(test,(1,1001))
thread.start_new_thread(test,(1000,2001))
if __name__=='__main__':
start()
......

ʵս¹¹½¨PythonºÍC++»ìºÏϵͳ

      ¹ØÓÚC++ºÍPythonÖ®¼ä»¥Ïàµ÷ÓõÄÎÊÌ⣬¿ÉÒÔ²éÕÒµ½ºÜ¶à×ÊÁÏ¡£±¾ÎĽ«Ö÷Òª´Ó½â¾öʵ¼ÊÎÊÌâµÄ½Ç¶È¿´ÈçºÎ¹¹½¨Ò»¸öPythonºÍC++»ìºÏϵͳ¡£
                       &nbs ......

£¨×ª£©Python×Ö·û´®µÄencodeÓëdecode isinstance

Ê×ÏÈÒª¸ãÇå³þ£¬×Ö·û´®ÔÚPythonÄÚ²¿µÄ±íʾÊÇunicode±àÂ룬Òò´Ë£¬ÔÚ×ö±àÂëת»»Ê±£¬Í¨³£ÐèÒªÒÔunicode×÷ΪÖмä±àÂ룬¼´ÏȽ«ÆäËû±àÂëµÄ×Ö·û´®½âÂ루decode£©³Éunicode£¬ÔÙ´Óunicode±àÂ루encode£©³ÉÁíÒ»ÖÖ±àÂë¡£
decodeµÄ×÷ÓÃÊǽ«ÆäËû±àÂëµÄ×Ö·û´®×ª»»³Éunicode±àÂ룬Èçstr1.decode('gb2312')£¬±íʾ½«gb2312±àÂëµÄ×Ö·û´®×ª»»³ ......

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

Àý1£º
# _018
# This is a module (if write Chinese in a module, there will be a error)
def func1():
print 'This is function 1.'
def func2():
print 'This is function 2.'
def func3():
print 'This is function 3.'
# 019
# ʹÓÓimport”Óï¾äµ÷ÓÃÄ£¿é£º
import _018_Module
_ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ