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

python dict µÄÄÚ´æ¿ØÖÆ

ϱßÊÇÎÒдµÄÒ»¶Î´úÂ룬Ëæ»úÉú³É100ÍòÌõ4ÁÐÊý¾Ý£¬²¢·Åµ½dictÀï±ß£¬È»ºó°ÑÄÚÈÝдµ½txtÎļþÖÐ

Python code:

#!/usr/bin/python2.5
import random
import time

time.sleep(5)
shapes = {}
print "--------------START---------------------------"
for i in range(1000000):
shape_id = str(random.randint(0, 10000))
r1 = str(random.randint(0, 1000000))
r2 = str(random.randint(0, 1000000))
r3 = str(random.randint(0, 1000000))
r4 = str(random.randint(0, 1000000))
shapes.setdefault(shape_id, []).append([r1, r2, r3, r4])
print '---------------Dictionary---------------------'
time.sleep(5)

f = open("test.txt", "w")
for shape_id, res in shapes.items():
for (r1, r2, r3, r4) in res:
f.write(shape_id + ',' + r1 + ',' + r2 + ',' + r3 + ',' + r4 + '\n')
f.close()



µ±ÎÒÖ´ÐеÄʱºò£¬Éú³ÉÁËshapesµÄʱºòÄÚ´æÕ¼Óõ½´ïÁË200MB¶à£¬µ«ÊÇÉú³ÉÎļþµÄʱºòÖ»ÓÐ30MB¶àÒ»µã£¬ÕâÊÇΪʲôÄÜ£¿Õâ¸ö°ì·¨ÄÜ·ñÓÐÓÅ»¯£¬ÒòΪÎÒ¿ÉÄÜÒªµ¼Èë500MµÄÎļþ£¬ÏñÕâÑùµÄ»°¿ÉÄÜÐèÒª3-4gµÄÄÚ´æ¿Õ¼äÀ´´æ´¢Ëü£¬µ«ÊDZ¾µØµÄÄÚ´æÏÔÈ»²»¹»£¬²»ÖªµÀ´ó¼ÒÓÐûÓа취À´ÓÅ»¯Ëü£¿

лл

лл¥ÉϵÄ
ÎÒµÄÎÊÌâÊÇ20mbµÄÊý¾Ýµ¼Èëµ½DICTÖУ¬ÄÚ´æÕ¼ÓÃÁË100¶àMB
Óа취½â¾öÕâ¸öÎÊÌâÂð£¿



ºÃÏñbsDDB Ö»Äܱ£´æString¡£
ÎÒµÄKEY ÊÇÒ»¸öID £¬¶ÔÓ¦×ÅÒ»¸ölist,list ÖÐÓкܶàtuple£¬ÀýÈç
123=>[(2,3,4),(3,4,5)...]
234=>[(2


Ïà¹ØÎÊ´ð£º

python Òì³£Í˳ö

×î½üÓÃpythonдһ¸ö³ÌÐò,×ÜÊÇÒì³£Í˳ö£¬µ«ÊÇȴû·¨ÓÃtry..exceptÀ´²¶×½

ÓÉÓÚû·¨·¢Í¼Æ¬£¬ËùÒÔ°ÑÏà¹ØµÄÐÅÏ¢´òÓ¡³öÀ´
Òì³£µÄÐÅÏ¢´óÖÂÈçÏ£º

python.exeÓöµ½ÎÊÌâÐèÒª¹Ø±Õ¡£ÎÒÃǶԴËÒýÆðµÄ²»±ã±íʾ±§Ç¸ ......

Python + Tkinter ´°¿ÚËõ·ÅÎÊÌâ

ѧϰÓÃpython+tkдÁËÒ»¸ö¼òµ¥½Å±¾£¬ÓÃÀ´ÏÔʾһЩͼƬºÍÆä˵Ã÷£¬Éè¼Æ2¸ö°´Å¥À´·­Ò³¡£¿Ø¼þ²ÉÓÃpack()·½Ê½£¬Ö÷´°¿ÚûÓÐÌرðÖ¸¶¨³ß´ç£¬°´Ï·­Ò³°´Å¥ºóÄÜ×Ô¶¯ÒÀ¾ÝÄÚÈÝ×Ô¶¯Ëõ·Å´óС£¬ÈçÔ¤ÆÚÉèÏë¡£²»¹ý±È½ÏÆæ¹ÖµÄÊÇ,Èç¹ûÓÃÊ ......

PythonÖÐÎÄ´¦Àí£¬Íê³É¹¦ÄܵÄʵÓû¯

±¾ÎÄÕª×Ô¡¶¿É°®µÄPython¡·¡°¹âÅ̹ÊÊ¡±CDay-1 ʵÓû¯ÖÐÎÄ¡£
[img]http://t.douban.com/mpic/s3901817.jpg[/img]
CDay-1 ʵÓû¯ÖÐÎÄÖÐÎÄ´¦Àí£¬Íê³É¹¦ÄܵÄʵÓû¯
ÄãÅöµ½99%µÄÎÊÌ⣬ÆäËûÈË֮ǰÒѾ­Óöµ½¹ýÁË£¬Ë ......

pythonÔõôprint 'hello world'

´ó¼ÒºÃ£¬ÎÒÊÇÒ»¸öÐÂÊÖ£¬¸Õ¿ªÊ¼Ñ§python£¬µ«ÊǸտªÊ¼µÄhelloworld¶¼Ã»·¨´òÓ¡£¬ÈÃÎÒºÜÎÞÄΡ£
ÎÒµÄpython°²×°Â·¾¶Îªf:\python31¡£ÔÚpathÖÐÒ²ÉèÖöÔÁË£¬ÔÚwindowsÏÂÔËÐÐÊÇÕâÑùÏÔʾµÄ£¬Ï£Íû¸÷λǰ±²Ö¸µãһϡ£Ð»Ð»
Pyth ......

Python¡¢LuaµÈÓïÑÔÖÐÊÇÈçºÎÅжÏÖ¸ÕëÊÇ·ñÓÐЧµÄ£¿

    Python¡¢LuaµÈ½Å±¾ÓïÑÔÖÐÒ»Çж¼ÊǶÔÏ󣬶ÔÏóÓÃÖ¸Õë±êʶ£¬µ«ÕâЩÓïÑÔÖÐÊÇÈçºÎÅжÏÖ¸ÕëÓÐЧµÄÄØ£¿
    ÀýÈ磬һ¸öº¯ÊýÖÐij¸ö²ÎÊýÊÇÖ¸Õ루ָÏòÒ»¸ö¶ÔÏ󣩣¬ÔÚº¯ÊýµÄÄÚ²¿ÊµÏÖÖУ¬Èç¹ûÖ±½Ó¶ÔÖ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ