摘要:
import cmathimport mathimport sysdef get_float(msg,allow_zero):x = Nonewhile x is None:try:x = float(input(msg))if not allow_zero and abs(x) < sys.float_info.epsilon:#float_info.epsilon为接近0值的浮点数,因计算机浮点数只能无限接近0print("zero is not allowed")x = Noneexcept ValueError as err:print(err)return 阅读全文
posted @ 2011-07-10 11:38
孤独的猫
阅读(640)
评论(0)
推荐(0)

浙公网安备 33010602011771号