28 lines
517 B
Python
28 lines
517 B
Python
"""
|
||
财政平衡率(%)
|
||
"""
|
||
from fastapi import APIRouter
|
||
from pydantic import BaseModel
|
||
|
||
|
||
INDEX = "财政平衡率(%)"
|
||
|
||
router = APIRouter()
|
||
|
||
|
||
class Params(BaseModel):
|
||
一般预算支出: float
|
||
一般预算收入: float
|
||
|
||
|
||
@router.post("/{}".format(INDEX))
|
||
def func(p: Params):
|
||
try:
|
||
result = p.一般预算收入 / p.一般预算支出 * 100
|
||
return round(result, 6)
|
||
|
||
except ZeroDivisionError:
|
||
return "算式无意义"
|
||
except Exception:
|
||
return "计算错误"
|