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

pythonÖеÄÁбíÅÅÐò²Ù×÷

 
 
 
Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable.
There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various manuals describing them, so I'll do so here.
 
Backward compatibility note
Many constructs given in the HOWTO assume Python 2.4. Before that, there was no sorted() builtin and list.sort() took no keyword arguments.
 
Sorting basic data types
A simple ascending sort is very easy: just call the sorted() function. It returns a new sorted list:
 
>>> print sorted([5, 2, 3, 1, 4])
[1, 2, 3, 4, 5]
You can also use the sort() method of a list. It modifies the list in-place (and returns None to avoid confusion). Usually it's less convenient than sorted() - but if you don't need the original list, it's slightly more efficient.
 
>>> a = [5, 2, 3, 1, 4]
>>> a.sort()
>>> print a
[1, 2, 3, 4, 5]
Sort takes an optional function which can be called for doing the comparisons. The default sort routine is equivalent to using cmp:
 
>>> print sorted([5, 2, 3, 1, 4], cmp)
[1, 2, 3, 4, 5]
where cmp() is the built-in function that compares two objects, x and y, and returns a negative number, 0 or a positive number depending on whether x<y, x==y, or x>y. During the course of the sort the relationships must stay the same for the final list to make sense.
If you want, you can define your own function for the comparison. For integers we can do:
 
>>> def numeric_compare(x, y):
>>> return x-y
>>>
Note that this does not work for numbers in general, as the comparison function must return integers.
For numbers in general, but a little more understandably:
 
>>> def numeric_compare(x, y):
>>> if x>y:
>>> return


Ïà¹ØÎĵµ£º

Python Firewall Win32 (pyfw

Python Firewall Win32 (pyfw-win32)
pyfw-win32ÊÇÒ»¸ö¿ÉÓÃPython½Å±¾¿ª·¢Êý¾Ý°ü¹ýÂË(·À»ðǽ)µÄÄ£¿é¡£µ×²ãʹÓÃCÓïÑÔ±àдµÄNDISÖмä²ãÇý¶¯(NDIS IMD)Ìṩ֧³Ö£¬ÉϲãÌṩPython¿ª·¢½Ó¿Ú¡£¿ÉÓÃPython½Å±¾´¦ÀíËùÓÐÂß¼­ÎÊÌ⣬¶ø²»±Ø¹ØÐĵײãʵÏÖ£¬´ïµ½¿ìËÙ¡¢Áé»î¿ª·¢µÄÄ¿µÄ¡£
Google ÏîÄ¿Íйܣº
http://code.google.com/p/py ......

PythonºÍPHPÖ®±È½Ï

  ż¶û×ö¸ö¼òµ¥µÄWEB·þÎñ²âÊÔ³ÌÐò£¬ÎÒ»¹ÊÇϲ»¶²ÉÓÃPHP¡£¼ò½à£¬·ç¸ñºÍC/C++½Ó½ü£¬ÉÏÊֿ죬¶øÇÒ¿âÒ²ºÜÆëÈ«¡£ÒÔǰΪ¹ã¶«Òƶ¯×öÒƶ¯ÐÐÒµÖն˵ÄÑÝʾ³ÌÐòʱ£¬²ÉÓùúÄÚÒ»¸öÐÖµÜдµÄFleaPHP¿ªÔ´¿ò¼Ü£¬Á½Öܲ»µ½µÄʱ¼ä£¬ÎÒ´ÓÒ»¸ö¶ÔPHPÒ»ÎÞËùÖªµÄˮƽ£¬¿ìËٵĸ㶨ÁË30¶à¸öÒ³ÃæµÄºǫ́£¬ºóÀ´ÑÝʾЧ¹ûÒ²²»´í£¬Ò²ºÜÎȶ¨£¬´Ó´Ë¶ÔPHPÓÐÁ ......

Python GUI

1. ʼþÇý¶¯
    Ò»¸öʼþ¼°Æä»Øµ÷µÄÀý×ÓÊÇÊó±êÒƶ¯¡£ÎÒÃǼÙÉèÊó±êÖ¸ÕëÍ£ÔÚÄúGUI ³ÌÐòµÄij´¦¡£Èç¹ûÊó±ê±»ÒƵ½Á˳ÌÐòµÄ±ð´¦£¬Ò»¶¨ÊÇÓÐʲô¶«Î÷ÒýÆðÁËÆÁÄ»ÉÏÖ¸ÕëµÄÒƶ¯£¬´Ó¶ø±íÏÖÕâÖÖλÖõÄתÒÆ¡£ÏµÍ³±ØÐë´¦ÀíÕâЩÊó±êÒƶ¯Ê¼þ²ÅÄÜÕ¹ÏÖ£¨²¢ÊµÏÖ£©Êó±êÔÚ´°¿ÚÉϵÄÒƶ¯¡£Ò»µ©ÄúÊÍ·ÅÁËÊó±ê£¬¾Í²»ÔÙ»áÓÐʼþÐèÒª´¦ ......

PythonǶÈëC++Ïê½â(3)

¼Ìǰƪ¡¶Import Module¡·£¨http://blog.csdn.net/xiadasong007/archive/2009/09/02/4512797.aspx£©£¬¼ÌÐø·ÖÎöǶÈ벿·Ö»ù´¡ÖªÊ¶¡£Õâ´Î²»¶à˵£¬ÓÐʲôÎÊÌâ¼ÇµÃ¶à²éÓ¢ÎÄ×ÊÁÏ£¬¹úÄÚµÄÕâ·½Ãæ֪ʶÉÙ
»¹ÊÇÀ´¿´´úÂ룬дÍêÎÒ¾Í˯¾õÁË~
 
#include "python/python.h"
#include <iostream>
using namespace std;
int ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ