
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 >>>
也就是在一行 写多条代码句时,加上分号。










