小编use*_*924的帖子

使用python中的子程序而不是if语句

我想知道我是否可以在这里使用子程序,如果是这样我或者是否有另一种缩短这段代码的方法.

    if currency1=='GBP':
        if currency2=='USD':
            number=float(1.64)
        elif currency2=='EUR':
            number=float(1.20552)
        elif currency2=='JPY':
            number=float(171.181)
Run Code Online (Sandbox Code Playgroud)

python if-statement subroutine

3
推荐指数
1
解决办法
244
查看次数

标签 统计

if-statement ×1

python ×1

subroutine ×1