python分号使用
不加分号代码
>>>classPerson:
name='tom'
age=18
>>>p1=Person()
>>>print(p1.age)
>>>
加分号代码:
>>>classStudent:
name='tom';
age=18;
>>>stu1=Student();
>>>print(stu1.age)
>>>
注:建议最好还是不加分号,因为python是考换行来区分代码句的,当然有时候也可以加上;
python使用分号的时候
>>>num1=1;num2=2;
>>>print(num1+num2);
>>>
也就是在一行写多条代码句时,加上分号。
以上内容为大家介绍了python培训之语句加分号吗,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注我们