update在python中什么意思,在python中|=是什么意思?

下面是python构建的交互式帮助(help()函数,非常简洁!)在help> |=

Augmented assignment statements

*******************************

Augmented assignment is the combination, in a single statement, of a

binary operation and an assignment statement:

augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)

augtarget ::= identifier | attributeref | subscription | slicing

augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="

| ">>=" | "<<=" | "&=" | "^=" | "|="

(See section *Primaries* for the syntax definitions for the last three

symbols.)

An augmented assignment evaluates the target (which, unlike normal

assignment statements, cannot be an unpacking) and the expression

list, performs the binary operation specific to the type of assignment

on the two operands, and assigns the result to the original target.

The target is only evaluated once.

An augmented assignment expression like ``x += 1`` can be rewritten as

``x = x + 1`` to achieve a similar, but not exactly equal effect. In

the augmented version, ``x`` is only evaluated once. Also, when

possible, the actual operation is performed *in-place*, meaning that

rather than creating a new object and assigning that to the target,

the old object is modified instead.

With the exception of assigning to tuples and multiple targets in a

single statement, the assignment done by augmented assignment

statements is handled the same way as normal assignments. Similarly,

with the exception of the possible *in-place* behavior, the binary

operation performed by augmented assignment is the same as the normal

binary operations.

For targets which are attribute references, the same *caveat about

class and instance attributes* applies as for regular assignments.

(END)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值