成都创新互联网站制作重庆分公司

创新互联Python教程:python语句加分号吗

python分号使用

不加分号代码

>>> class Person:
    name = 'tom'
    age = 18

    >>> p1 = Person()
>>> print(p1.age)
>>>

推荐学习《python学习网》

加分号代码:

>>> class Student:
    name = 'tom';
    age = 18;

>>> stu1 = Student();
>>> print(stu1.age)
>>>

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

python 使用分号的时候

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

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


当前题目:创新互联Python教程:python语句加分号吗
当前网址:http://cxhlcq.com/article/dhhsdgs.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部