问题描述
我遇到了这样的签名函数:
// Keys and values held here.
myMap = Map<string,mixed>;
const [data,setData] = useState(() => {
const data = {
submit: 0,// Set data that I know the keys of here.
};
// Set data that I don't know the keys of here.
// I am trying to dynamically set data[key] as follows (which does not work):
Object.keys(myMap).forEach(key => data[key] = myMap[key]);
return data;
});
是什么意思?
这是我的python 3.8的语法错误。我是否需要从def get_quantile(numbers: List[float],q: float | int ) -> float | int | None :
导入某些内容才能使其正常工作?
解决方法
根据PEP 604,|
将用于指定Python 3.10中的联合类型。
所以float | int
的意思是Union[float,int]
,即浮点数或整数。
表示or
。因此,q: float | int
意味着q
可以是float
或int
。