python里有分号吗

图片[1]-python里有分号吗-uusu优素-乐高,模型,3d打印,编程

python分号使用

每一条语句最后个加个分号;这是c,oc,java,php等语言中不可缺少的部分,但是对于python,分号是可加,可不加的

如:不加分号代码

>>>classPerson:
name='tom'
age=18
>>>p1=Person()
>>>print(p1.age)
>>>

推荐学习《python教程》

加分号代码:

>>>classStudent:
name='tom';
age=18;
>>>stu1=Student();
>>>print(stu1.age)
>>>

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

python 使用分号的时候

>>>num1=1;num2=2;
>>>print(num1+num2);
3
>>>
原文来自:https://www.py.cn
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容