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

ÓÃPython»­Mandelbrot¼¯

¡¡¡¡Mandelbrot Set£¨ÂüµÂ²ªÂÞ¼¯£©¿ÉÄÜÊÇ·ÖÐÎͼÐÎÖÐ×îÓÐÃûµÄͼÐΣ¬¹ØÓÚËüµÄ½éÉÜÎҾͲ»¶àдÁË£¬ÓÐÐËȤµÄ¿ÉÒԲο¼Õâ¸öÁ´½Ó ¡£ÏÂÃæÊǹØÓÚÈçºÎʹÓÃPythonÀ´»­Õâ¸öͼÐεij¢ÊÔ¡£

¡¡¡¡ÓÉÓÚPython±ê×¼¿âÖл¹Ã»ÓжÔͼÐδ¦ÀíµÄÖ§³Ö£¬ÔÚ´ËÎÒʹÓÃÁËPIL ¡£ÏÈÀ´¿´Ò»ÕÅÉú³ÉµÄͼÐΣº

¡¡¡¡

¡¡¡¡Ïà¹ØµÄ´úÂë´óÖÂÊÇÕâÑùµÄ£º

¡¡¡¡Python code:
# -*- coding: utf-8 -*-
# http://blog.csdn.net/oldjwu/
# z<n+1> = z<n> ^ 2 + c

import time
import Image, ImageDraw

g_size = (600, 450) # ͼÐÎ×îÖճߴç
g_maxIteration = 256 # ×î´óµü´ú´ÎÊý
g_bailout = 4 # ×î´óÓò
g_zoom = 2.5 / g_size[0] # Ëõ·Å²ÎÊý
g_offset = (-g_size[0] * 0.25, 0) # Æ«ÒÆÁ¿

def draw(antialias = True):
zi = 1
if antialias: # ¿¹¾â³Ý
zi = 2
size = [i * zi for i in g_size]
zoom = g_zoom / zi
offset = [i * zi for i in g_offset]
bailout = g_bailout * zi
img = Image.new("RGB", size, 0xffffff)
dr = ImageDraw.Draw(img)

print "painting Mandelbrot .."
for p in getPoints(size, offset, zoom):
dr.point(p[0], fill = p[1])
print "%s100%%" % ("\b" * 10)

del dr
if antialias:
img = img.resize(g_size, Image.ANTIALIAS)
# img.show()
img.save("mandelbrot.png")

def getPoints(size, offset, zoom, ti = 0, tstep = 1):
"Éú³ÉÐèÒª»æÖƵ


Ïà¹ØÎÊ´ð£º

python Òì³£Í˳ö

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

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

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

python½Ì³ÌÖÐʹÓÃÔ´ÎļþµÄÎÊÌâ~~

ʹÓÃÔ´Îļþ

#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'

ÎÒÔõôҲ¿´²»¶®£¡Ö»ÊÇ×îºóÒ»ÐÐÎÒÖªµÀ~~Ç°ÃæÁ½ÐÐÊÇʲôÒâ˼ÄØ£¿
½Ì³ÌÉÏ˵Èç¹ûÄãʹÓÃIDLE£¬ÇëʹÓò˵ ......

pythonÔõôprint 'hello world'

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

boost.python c++ǶÈëpythonÈçºÎÖØÔØ=£¿

ÎÒÏÖÔÚÓÐÒ»¸öÐèÇóÊÇÕâÑùµÄ
ÎÒÓÐ2¸öÀà
class A
{
public:
int val;
}

class B
{
public:
A a
}

ÏÖÔÚÔڽű¾ÖÐÖ»ÄÜ
b.a.val = 1
ÎÒÔÚpythonÖÐÏëʹÓÃ
b.a = 1
......

pythonÈçºÎÉèÖÃCLOSE_WAIT״̬ռÓõĶ˿ÚÖØÓÃ

·¢ÏÖpython2.6
import httplib
conn=httplib.HTTPSConnection('x.x.x.x')
conn.request('','')
rd=conn.getresponse()
conn.close()
ÕâÑù½áÊøºó»á±ä³ÉCLOSE_WAIT״̬£¬ÎÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ