如何使用 Python 从货币符号中 deduce/print 货币代码?

How to deduce/print the currency code from the currency symbol using Python?

我有一些文件,我从中提取了货币符号,如 €、£、$ 等

我想在 python 中编写代码,在读取这些符号后,它可以给我相应的货币代码作为输出。

例如。如果我得到货币符号 ,输出应该是 EURO 或者如果货币符号是 $ 输出应该是 USD

使用 Dictionary。这些就像哈希表。

currency = { "€": "EURO", "$": "USD" }
print (currency["$"])

打印 USD