zoukankan      html  css  js  c++  java
  • python分号使用

    一:python分号使用

    每一条语句最后个加个分号;这是c,oc,java,php等语言中不可缺少的部分,但是对于python,分号是可加,可不加的

    如:不加分号代码

    >>> class Person:
        name = 'tom'
        age = 18
    
        
    >>> p1 = Person()
    >>> print(p1.age)
    18
    >>> 

    加分号代码:

    >>> class Student:
        name = 'tom';
        age = 18;
    
    >>> stu1 = Student();
    >>> print(stu1.age)
    18
    >>> 

     注:建议最好还是不加分号,因为 python 是考换行来区分代码句的,当然有时候也可以加上;

    二:python 使用分号的时候

    >>> num1 = 1; num2 =2;
    >>> print(num1+num2);
    3
    >>> 

      就是在一行 写多条代码句时,加上 分号;

  • 相关阅读:
    The first appliaction for "Hello World!"
    zone
    learn to study
    深入理解 Angular 2 变化监测和 ngZone
    看看吧
    生命周期钩子
    一个简单的todo
    依赖注入
    @Output()
    @Input
  • 原文地址:https://www.cnblogs.com/cocoajin/p/3671995.html
Copyright © 2011-2022 走看看