python分號(hào)使用
不加分號(hào)代碼
>>>classPerson:
name='tom'
age=18
>>>p1=Person()
>>>print(p1.age)
>>>
加分號(hào)代碼:
>>>classStudent:
name='tom';
age=18;
>>>stu1=Student();
>>>print(stu1.age)
>>>
注:建議最好還是不加分號(hào),因?yàn)閜ython是考換行來(lái)區(qū)分代碼句的,當(dāng)然有時(shí)候也可以加上;
python使用分號(hào)的時(shí)候
>>>num1=1;num2=2;
>>>print(num1+num2);
>>>
也就是在一行寫多條代碼句時(shí),加上分號(hào)。
以上內(nèi)容為大家介紹了python培訓(xùn)之語(yǔ)句加分號(hào)嗎,希望對(duì)大家有所幫助,如果想要了解更多Python相關(guān)知識(shí),請(qǐng)關(guān)注IT培訓(xùn)機(jī)構(gòu):千鋒教育。