以下是Python的基础语句大全:
-
变量定义语句:
var_name = var_value
-
输出语句:
print(var_name)
-
输入语句:
var_name = input()
-
条件语句:
if condition:// do something if condition is True elif condition:// do something if previous conditions were False and this condition is True else:// do something if all the previous conditions were False
-
循环语句:
for var in iterable:// do something for each item in iterable
-
函数定义语句:
def function_name(parameter1, parameter2, ...):// do something with parametersreturn value
-
类定义语句:
class Class_name:def __init__(self, parameter1, parameter2, ...):// initialize object with parametersdef method_name(self, parameter1, parameter2, ...):// do something with objectreturn value
-
异常处理语句:
try:// do something that may raise an exception except ExceptionType:// handle the
感谢你们的阅读和喜欢,我收藏了很多技术干货,可以共享给喜欢我文章的朋友们,如果你肯花时间沉下心去学习,它们一定能帮到你,干货内容包括: ![在这里插入图片描述](https://img-blog.csdnimg.cn/de14fd28c8a448f8843222321e108875.jpeg#pic_center)
今天的内容就分享到这里,如果你喜欢这篇文章的话,麻烦请动动你的手点个赞或者点个关注吧,这将是我最大的动力!谢谢,这里有我以前整理的大量自学资料