海象运算符

Python 3.8功能 (Python 3.8 Feature)

Walrus operator is the coolest feature that was added in the Python 3.8 update, the Python release that most of you are probably using right now. The operator := is called the walrus operator since it characterizes the look of the walrus. See the colon as eyes and the equal sign as its tusks.

Walrus运算符是Python 3.8更新中添加的最酷的功能,这是大多数人现在可能正在使用的Python版本。 :=运算符称为海象运算符,因为它表征了海象的外观。 将结肠视为眼睛,将等号视为其牙。

The walrus operator is used as an assignment expression. It allows you to assign a value to a variable while also returning the value.

海象运算符用作赋值表达式。 它允许您为变量分配一个值,同时还返回该值。

那么我们该如何使用呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值