python studying ---- memo and difference compared to c++

1. expression ends

      not use ; to end one sentence,  it just like marco define in c++

2. block of codes

     use : to perform the same function as {} in c++ define of  block of codes

3. object construction

    use function: __init__
            def __init__(self):
            def __init__(self,  parameter = default_value, parameter = default_vaule):

4. operator overidding

     def __add___(): ------------- add/radd
                 sub, mul, div, pow etc.


5. logical operators

    and, or, not

6. name restrictive  

    start a letter or an underscore,  follow any-length letter, number, underscore

7. import a name.py file

    >>> from name import *              ----------- just as has type the name.py into interpreter
                  note: not the name.py
                  This statement imports all the de nitions from name and places them into the global scope

    >>> import  name
                  This creates a new scope that is separate from the global scope (but is enclosed by the global scope)


8. build_in function print()

    print(parameter, parameter, sep="value",  end="value")
                             sep is the value used to seperator the parameters(the default value is a space ),  end is the value used to put at the end when print the parameter done(the default value is newline)

9. class's __mro__ attribute

      list the  order of based class  that the class inherited 

10.  _

     in interactive session, the _ means the result of last operation
             
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值