1,Python实际物理实现。

    IronPython:微软主导,DRL动态语言驱动。不支持任何常规Python三方类库。 最新版本:2.7。正在研究中。

    CPython:标准版本。

    StackLess:无限制堆栈版本。

    JPython:基于Java实现, WAS使用作配置文件(确实,很好用)。听说有Django版本了。

 

2,Python对比其他静态语言的语法糖。

     支持关键字:and ( &&) or(||)  not(!)

     3<4 and 4<5 简写 3<4<5

  

     不支持赋值语句 ++ 和 --

    

     Python默认支持6中数字类型: int long   bool   float   complex(负数)  decimal 整数型

     decimal用于支持 1.1  结果是1.10000001  而decimal.Decimal('1.1')  结果是 1.1

 

     字符串切片:

     pystr = 'geewu hello world'

     pystr[0]

     pystr[2:5]

     pystr[:2]

     pystr[3:]

     pystr[-1]  倒数第一个字母

     pystr[::-2]           pystr[start:end:步进] 

 

     内置列表和元组,还有字典

     列表 aList = [1,2,3,4]                  元组 tuple=(1,2,3,4) 不能修改   字典 aDist = {"hello1":'123123'};

 

     for循环+range()内建函数

     for item in [1,2,3]   等价于 for item in range(1,3)

 

    enumerate()方法

    foo = 'abc' 

    for i in range(len(foo)):                                等价           for i,ch  in enumerate(foo): 

           print foo[i],'(%d)' % i                                                print ch,'(%d)' %i

 

    列表解析

    squared = [x **2 for x in range(4)]

    for i in squared:

             print i

      

       squared = [x **2 for x in range(4) if not x % 2]

    for i in squared:

             print i

 

     特殊继续符号(\)

     #check condition

     if(weather_is_hot==1) and \

      (shark_warning ==0):

                         send_goto_beach_mesg_to_pager()

         

     

     判断特殊关键字的函数 iskeyword()

 

常用相关工具

调试器: pdb。

        记录器: logging。

        性能测试器: profile, hostshot , cProfile

 

 

   Python内置对象。

   默认 None 空对象。 布尔值永远都是False

   都是False的对象。

   None, False,所有为0的数,0, 0.0 , 0L, 0.0+0.0j , '',"" , [] , (), {} 

 

   id()获取用户的声明变量的位置  a is b  等价与  id(a) == id(b)

  

   if type(num) is types.IntType 

    

    

 

posted on 2011-07-02 18:27  geewu  阅读(842)  评论(0编辑  收藏  举报