这是一个简单的程序,可以计算一些蒸汽特性
import numpy as np
from iapws import IAPWS97
sat_steam=IAPWS97(P=0.1,T=373.15)
sat_liquid=IAPWS97(T=100+273.15, x=0)
steam=IAPWS97(P=2.5, T=500)
print(sat_steam.s, sat_liquid.P, steam.h) #calculated properties
如何输出数字,以便仅显示一个小数位?
谢谢
答案 0 :(得分:0)
使用官方文档https://docs.python.org/3.6/library/functions.html#round
中的round()
功能
import numpy as np
from iapws import IAPWS97
sat_steam=round(IAPWS97(P=0.1,T=373.15), 1)
sat_liquid=round(IAPWS97(T=100+273.15, x=0), 1)
steam=round(IAPWS97(P=2.5, T=500), 1)
print(sat_steam.s, sat_liquid.P, steam.h) #calculated properties