Python3.8:合并运算符(|)有什么用?

Python3.8: What is the merge operator(|) good for?

在python3.9中,合并运算符(|)用于将字典合并在一起。有点像这样:

foo = {1:'spam', 'eggs':2}
bar = {3:'foo', 'eggs':'foo'}
foobar = foo|bar

但是 python3.8 及更低版本中的合并运算符除了将字典合并在一起之外如何使用?

| 运算符有魔术方法 __or__。也用于表达set union(合并),以及按位或。