摘要:
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 阅读全文
摘要:
subprocess被用来替换一些老的模块和函数,如:os.system、os.spawn*、os.popen*、popen2.*、commands.*。可见,subprocess是被推荐使用的模块。 阅读全文