pythonÖÐÈçºÎÅжÏÒ»¸ö±äÁ¿µÄÊý¾ÝÀàÐÍ£¿(Ô´´)
import types
type(x) is types.IntType # ÅжÏÊÇ·ñint ÀàÐÍ
type(x) is types.StringType #ÊÇ·ñstringÀàÐÍ
.........
--------------------------------------------------------
³¬¼¶¶ñÐĵÄģʽ£¬²»ÓüÇסtypes.StringType
import types
type(x) == types(1) # ÅжÏÊÇ·ñint ÀàÐÍ
type(x) == type('a') #ÊÇ·ñstringÀàÐÍ
------------------------------------------------------
ʹÓÃÄÚǶº¯Êý£º
isinstance
(
object, classinfo
)
Return true if the object
argument is an instance
of the classinfo
argument, or of a (direct or indirect)
subclass thereof. Also return true if classinfo
is a type
object and object
is an object of that type. If object
is not a class instance or an object of the given type, the function
always returns false. If classinfo
is neither a class
object nor a type object, it may be a tuple of class or type objects,
or may recursively contain other such tuples (other sequence types are
not accepted). If classinfo
is not a class, type, or
tuple of classes, types, and such tuples, a TypeError
exception is raised. Changed in version
2.2: Support for a tuple of type information was added.
Python¿ÉÒԵõ½Ò»¸ö¶ÔÏóµÄÀàÐÍ £¬ÀûÓÃtypeº¯Êý£º
>>>lst = [1, 2, 3]
>>>type(lst)
<type 'list'>
²»½öÈç´Ë£¬»¹¿ÉÒÔÀûÓÃisinstanceº¯Êý£¬À´ÅжÏÒ»¸ö¶ÔÏóÊÇ·ñÊÇÒ»¸öÒÑÖªµÄÀàÐÍ¡£
isinstance˵Ã÷ÈçÏÂ:
isinstance(object, class-or-type-or-tuple) -> bool
Return whether an object is an instance of a class or of a subclass
thereof.
With a type as second argument, return whether that is the object's
type.
The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut
for
isinstance(x, A) or isinstance(x, B) or ... (etc.).
ÆäµÚÒ»¸ö²ÎÊýΪ¶ÔÏ󣬵ڶþ¸öΪÀàÐÍÃû»òÀàÐÍÃûµÄÒ»¸öÁÐ±í¡£Æä·µ»ØÖµÎª²¼¶ûÐÍ¡£Èô¶ÔÏóµÄÀàÐÍÓë²ÎÊý¶þµÄÀà
Ïà¹ØÎĵµ£º
python
ÓïÑÔ¸ÅÀÀ
python
½Å±¾¿ÉÒÔ´¦ÀíÍⲿ´«½øÀ´µÄ²ÎÊý ¼´sys.argv[]
£¬argv[]
µÄʹÓÃÓëlinux
ÏÂÏàͬ
python
±¾ÉíÊǽâÊÍÓïÑÔ£¬¿ÉÒÔ¶ÔÊäÈëµÄʽ×ÓÇóÖµ¡£python
Ö§³ÖµÄ¶ÔÏóÈçÕûÊý¶¼ÊÇÁ¢¼´Êý£¬´ËÍâËûÖ§³Ö¸´Êý£¬¼°¶ÔËÄÔòÔËËã½âÊÍ¡£
ptyhon
Ö§³Ö×Ö·û´®£¬·ÅÔÚµ¥/
Ë«ÒýºÅÄÚ£¬×Ö·û´®ÊÇÊý×飬¿ÉÒÔͨ¹ý[i: ......
Ó¢ÎİæDive in python¿ÉÒÔÔÚÏÂÃæÕÒµ½ÖÐÎÄ·Òëhttp://linuxtoy.org/docs/dip/toc/index.html
Ä£¿éµÄ__name__£¬µ±Ä£¿é±»importʱ£¬ÆäΪģ¿éµÄÃû×Ö£¬µ±Ä£¿é×÷ΪmainÖ´ÐеÄʱºò£¬ÆäΪ__main__
´ÊµäµÄkeyÊÇ´óСдÃô¸ÐµÄ¡£
ListÒ²Ö§³ÖÖØÔØ+²Ù×÷£¬ÓÃÓÚ½«Á½¸ölistÁ¬½ÓÆðÀ´£¬²¢·µ»ØÒ»¸öList£¬Òò´ËËüûÓÐextendedÖ´ÐиßЧ¡£listÒ²+ ......
ǰһƪÎÄÕÂдµÄÔÚAPACHE°²×°MOD_PYTHONµÄ¾¹ý,Æäʵͦ¼òµ¥,¾ÍÊǰ汾²»¼æÈݵÄÎÊÌâ.Õâ´ÎÎÒ´ó¸Å˵ϲ¿ÊðDJANGOµÄ¹ý³Ì.
ÏÈÐÞ¸ÄAPACHEÅäÖÃÎļþ,ʹÆä¼ÓÔØmod_pythonÄ£¿é
LoadModule python_module libexec/mod_python.so
ÔËÐÐÃüÁî²é¿´
bin/httpd -M¿ÉÒÔ¿´µ½
python_module (shared)
Syntax OK
˵Ã÷apacheÒѾ³É¹¦¼Ó ......
С°×¶ÔÉϽڿÎÀïµÄ“СÂéȸ”ÐËȤ°»È»£¬ÕûÌì¾ÍÔÚËÞÉáµ·¹Ä¡£Õâ²»£¬¼¸ÌìÏÂÀ´ËûÒѾ¹¥ÏÂÊ®¼¸¸öÍøÕ¾ÁË¡£
С²Ëȴϲ»¶Ò»¸öÈË×øÔÚµçÄÔÅԱߣ¬Öå×Åüͷ£¬ÐÀÉÍ×ÅÕâÒ»ÐÐÐÐ×Ô¼º¿´²»¶®µÄ´úÂë¡£“ÕâЩ×Ö·ûºÃ¹ÖÒìѽ£¡”С²ËÍá×ÅÍ·£¬“ËüΪɶ½ÐÕýÔò±í´ïÊ½ÄØ£¿”
°Ù¶Èһϣ¬ÖÕÓÚÖªµÀ¡£Ð¡² ......