0
点赞
收藏
分享

微信扫一扫

leetcode 每日一题

小亦同学321 2024-09-14 阅读 37

文章目录

一、 基础语法

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)
举报

相关推荐

0 条评论