通过Python AI工具生成日常SAP项目中的数据模型,方便用户进行测试运算。
main · Streamlit (inscode.run)https://works-ipo6616b48d00639142903c2864-8501.node01.inscode.run/
import streamlit as st
def calc_tax_price(price, tax_rate):
return price * (1 + tax_rate)
def save_last_price(price):
with open('last_price.txt', 'w') as f:
f.write(str(price))
def get_last_price():
try:
with open('last_price.txt', 'r') as f:
last_price = float(f.read())
return last_price
except:
return 0.0
st.title('含税价模型')
st.header('输入不含税价格,计算含税价格')
# 获取上次价格
last_price = get_last_price()
if last_price > 0.0:
st.subheader(f'上次查询的价格为 {last_price} 元')
# 输入价格和税率
price = st.number_input('请输入不含税价格(元)', value=last_price)
tax_rate = st.slider('请选择税率', 0, 100, 20)
# 计算含税价格
tax_price = calc_tax_price(price, tax_rate / 100.0)
# 保存价格
if price != last_price:
save_last_price(price)
# 显示含税价格
st.subheader(f'含税价格为 {tax_price:.2f} 元')
Done.
Created on 10th April, 2024
SAP Python AI模型(SAP Python AI Model Catalogue): To Be Continue...
上一篇(Previous Article): To Be Continue...
下一篇(Next Article): To Be Continue...