此Python代码有什么作用?括号说明

时间:2019-05-27 23:40:05

标签: python

您能解释一下这些行吗? 我不明白括号(j,pbase)中发生了什么。

mults = {}
if c in mults:
    (j,pbase) = mults.pop(c)

3 个答案:

答案 0 :(得分:2)

打开元组的包装:

(j,pbase) = mults.pop(c)

与:

x = mults.pop(c)
j = x[0]
pbase = x[1]

答案 1 :(得分:1)

a,b = something

这意味着something是两个值的序列。 a被分配给第一个值,b被分配给第二个值。

这称为元组拆包

答案 2 :(得分:0)

它删除字典import React from "react"; import { CardContainer } from "./card.style"; import { deepCompare } from "../../utils/"; const Card = ({ children }) => { return <CardContainer>{children}</CardContainer>; }; // if return true - Card component won't re-render const arePropsEqual = (preProps, newProps) => { return deepCompare(preProps, newProps); // <- function that compare the nested props. }; export default React.memo(Card, arePropsEqual); 的项c,然后将其键和值分别存储在multsj中。