python中可以使用分号“;”来分割代码,使所有代码可以写在同一行:
print "How can i write python in a line? \n"; print "You can use ';' follow the sentence. " ; print "Then run the script!"; print; print "Done."
在C、Java等语言的语法中规定,必须以分号作为语句结束的标识。Python也支持分号,同样用于一条语句的结束标识。但在Python中分号的作用已经不像C、Java中那么重要了,Python中的分号可以省略,主要通过换行来识别语句的结束。
更多Python知识请关注
Copyright © 2019- huatuowenda.com 版权所有 湘ICP备2023022495号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务