文章目录
一、 基础语法
1、缩进规则
def greet_user():
print("hello world")
greet_user()
2、标识符
- 单下划线开头:
_foo
的代表不能直接访问的类属性,需通过类提供的接口进行访问,不能用from xxx import *
而导入。 - 双下划线开头:
__foo
代表类的私有成员。 - 双下划线开头和结尾:
__ foo__
代表 Python 里特殊方法专用的标识,如__init__()
代表类的构造函数。
3、多行语句
item_one = 1
item_two = 2
item_three = 3
total = item_one + \
item_two + \
item_three
print(total)