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

pythonѧϰ

     ÔÚpythonÖУ¬ÈκÎÊý¾ÝÀàÐͶ¼ÊÇ“¶ÔÏ󔣬°üÀ¨pythonÌṩµÄÄÚÖöÔÏó£¬Ò²°üÀ¨Óû§Í¨¹ýpythonÓïÑÔ»òÕßCÀ©Õ¹¿â´´½¨µÄ¶ÔÏó¡£
     pythonµÄ¶ÔÏóÊǶ¯Ì¬ÀàÐÍ£¬¶øÇÒÊÇÇ¿ÀàÐÍ£¬ÕâÒâζ×ÅÖ»ÓÐÀàÐÍÆ¥ÅäµÄʱºò²ÅÄܽøÐÐÏàÓ¦µÄ²Ù×÷¡£ÏÖÔÚ£¬ÎÒÃÇÀ´Ñ§Ï°pythonµÄÄÚÖöÔÏó£¬pythonµÄÄÚÖöÔÏóÖ÷Òª°üÀ¨£º
1¡¢Numbers Êý×ÖÀàÐÍ
     pythonÖеÄNumbersÀàÐÍÄܹ»±íʾʵÊý¡¢¸¡µãÊý¡¢ÎÞÏß³¤¶ÈµÄ³¤ÕûÊý¡¢´øÐ鲿µÄ¸´Êý¡¢¹Ì¶¨¾«¶ÈµÄÊ®½øÖÆÊýÒÔ¼°¼¯ºÏ(sets)µÈ¡£
 pythonÖеÄNumbersÀàÐÍÖ§³Ö¼Ó(+)¡¢¼õ(-)ÒÔ¼°Ö¸Êý(**)²Ù×÷µÈ¡£
ÏÂÃæ¿´ÏÂpythonµÄÊý×ÖÀàÐ͵ıí´ïʽ¼ÆË㣺
 
      ×¢Ò⣬ÉÏͼÖÐL±íʾÕâ¸öÊýÊdz¤ÕûÊý£¬ÁíÍ⸡µãÊý6.282799...99ÊÇÈ«¾«¶ÈµÄ±íʾ·½Ê½£¬¶ø6.283 ÊÇÓû§ÓѺõıíʾ·½Ê½£¬ÏµÍ³»á×Ô¶¯µÄËÄÉáÎåÈë¡£
      ÔÚpythonÖУ¬¿ÉÒÔµ÷ÓÃÄÚÖÿâ¶ÔÊý×Ö¶ÔÏó½øÐвÙ×÷£¬±ÈÈçmath¿â¡¢random¿âµÈ¡£
×¢Ò⣺random.random(),»á·µ»ØÒ»¸ö[0-1)Ö¸¼âµÄʵÊý£¬random.choice(...)ÔòËæ»ú·µ»ØlistÖеÄÒ»¸öÔªËØ¡£
2¡¢strings ×Ö·û´®ÀàÐÍ
     ÔÚpythonÖУ¬stringsÊÇÒ»¸ö˳ÐòÈÝÆ÷£¬±íʾһ¸ö×Ö½ÚÐòÁУ¬±ÈÈçÎı¾ÐÅÏ¢£¬ºóÃæÎÒÃÇ»¹»áÅöµ½ÆäËü˳ÐòÈÝÆ÷£¬±ÈÈçlist£¬ËüÒ²¿ÉÒÔ±ðµÄ¶ÔÏóµÄÒ»¸öÓÐÐò¼¯ºÏ¡£
    pythonÖеÄstringsÀàËÆÓÚc++ÖеÄstring...
ÏÂÃæ¿´Ò»Ð©stringsµÄ²Ù×÷£º
     ¿ÉÒÔ¿´µ½£¬Äܹ»ºÜ·½±ãͨ¹ýÊý×éϱ귽ʽÀ´²Ù×÷strings£¬·µ»ØÄ³¸öÔªËØ»òÕßij¸ö·¶Î§µÄÔªËØ¼¯ºÏ£¬¸üÆæÃîµÄÊÇ¿ÉÒÔͨ¹ý¸ºË÷Òý´Ó·´ÏòÀ´È¡µÃ×Ö·û¡£
    ÁíÍ⣬ÎÒÃÇ»¹ÄÜͨ¹ý+À´Á¬½Ó2¸ö×Ö·û´®ÒÔ¼°Í¨¹ý*À´¸´ÖÆ×Ö·û´®¡£ÁíÍâstringsÀàÐÍ»¹¾ßÓв»¿É¸Ä±äÐÔ(immutable)£¬Äã²»ÄÜͨ¹ýs[1] = 'a' ÕâÑùµÄ·½Ê½À´¸Ä±äsÖеÄÔªËØ£¬µ«¿ÉÒÔͨ¹ý±í´ïʽÀ´ÕûÌå¸Ä±äsµÄÖµ¡£Ê¾ÀýÈçÏÂͼËùʾ£º
 ´®ÀàÐÍ»¹ÓÐÒ»Ð©ÌØÊâµÄ²Ù×÷£¬±ÈÈç²éÕÒ×Ó´® s.find('12'),³É¹¦·µ»Ø×Ó´®µÚÒ»¸öÔªËØµÄË÷Òý£¬·ñÔò·µ»Ø0£¬ÒÔ¼°ÆäËûһЩ²Ù×÷£¬ÕâÐ©ÌØÊâµÄ²Ù×÷¶¼ÊÇͨ¹ýs.method()µÄÐÎʽʵÏֵġ£
¿ÉÒÔͨ¹ýdirÏÔʾstringsµÄËùÓÐÊôÐÔ£¬Í¨¹ýhelp(s.index)ÕâÑùµÄÐÎʽ²é¿´°ïÖú¡£
 ºÍcÓïÑÔÀàËÆ£¬¿ÉÒÔÔÚ×Ö·û´®ÖмÓÈë¿ØÖÆ·ûÐÅÏ¢£¬±ÈÈç\t, \0µÈ£¬ËûÃÇÒ²Õ¼Ò»¸ö×Ö·û£¬×¢ÒâÔÚpythonÖÐ\0²¢²»ÊÇ×Ö·û´®µÄ½áÊø±êÖ¾¡£
È磺s = 'a\tb\0\c'
len(s)
5
ord(s


Ïà¹ØÎĵµ£º

Python: ʹÓÃ×°ÊÎÆ÷¡°@¡±È¡µÃº¯ÊýÖ´ÐÐʱ¼ä

¡¡¡¡PythonÖпÉÒÔʹÓÃ×°ÊÎÆ÷¶Ôº¯Êý½øÐÐ×°ÊΣ¨»ò˵°ü×°£©£¬ÀûÓÃÕâ¸öÌØÐÔ£¬¿ÉÒԺܷ½±ã¡¢¼ò½àµØ½â¾öһЩÎÊÌ⣬±ÈÈç»ñµÃº¯ÊýÖ´ÐÐʱ¼äµÄÎÊÌâ¡£
¡¡¡¡Ê×ÏÈ£¬ÎÒÃǶ¨ÒåÒ»¸öº¯Êý£¬ÈçÏ£º
¡¡¡¡def exeTime(func):
def newFunc(*args, **args2):
t0 = time.time()
print "@%s, {%s} start" % (time.strftime("%X", time.local ......

pythonµÄwiki ÁÐ×Ó.

#coding=utf-8
from newtest.wiki.models import WiKi
from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response

def index(request, pagename=""):
"""ÏÔʾÕý³£Ò³Ã棬¶ÔÒ³ÃæµÄÎÄ×Ö×öÌØÊâµÄÁ´½Ó´¦Àí"""
......

Boost Python ʵÏÖCµ÷ÓÃpython´íÎó½â¾ö·½·¨

ÓÉÓÚBoost Python¸ú²»ÉÏPython°æ±¾¸üУ¬ÈçÏ·½·¨µ÷ÓÿÉÄܲúÉúTypeError: 'NoneType' object does not support item assignmentÒì³£¡£
Boost PythonÎĵµÖÐÀý×Ó¿ÉÄܲúÉúÒì³£¡£
Py_Initialize();
object main_module = import("__main__");
object main_dict = main_module.attr("__dict__");
try{
   object ......

Python×Ö·û´®±àÂë

ÔÚPythonÖÐÓÐÐ©ÌØÊâµÄµØ·½ÊÇ´æÔÚÁ½ÖÖ×Ö·û´®£¬·Ö±ðΪstrºÍunicode×Ö·û´®£¬ËûÃǶ¼¼Ì³Ð×Ôbasestring¡£
È磺s="hello world"£¬sΪstr£»us=u"hello world"£¬usΪunicode¡£
ʹÓÃhelp(str)ºÍhelp(unicode)¿ÉÒԲ鿴¸÷×Ô˵Ã÷£¬ËûÃǶ¼ÓÐdecode¡¢encode·½·¨£¬
decodeÓÃÓÚ½«str×Ö·û´®½âÂëΪunicode×Ö·û´®£¬
encodeÓÃÓÚ½«unicode×Ö·û ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ