python分號使用
不加分號代碼
>>>classPerson:
name='tom'
age=18
>>>p1=Person()
>>>print(p1.age)
>>>
加分號代碼:
>>>classStudent:
name='tom';
age=18;
>>>stu1=Student();
>>>print(stu1.age)
>>>
注:建議最好還是不加分號,因為python是考換行來區(qū)分代碼句的,當然有時候也可以加上;
python使用分號的時候
>>>num1=1;num2=2;
>>>print(num1+num2);
>>>
也就是在一行寫多條代碼句時,加上分號。
以上內容為大家介紹了python培訓之語句加分號嗎,希望對大家有所幫助,如果想要了解更多Python相關知識,請關注IT培訓機構:千鋒教育。