Python超级超级简易计算器---Map映射写法
一开始没效果,根据小甲鱼教程的map例子重复对了15分钟,最后自己发现要加一个*来解收集函数.....教程上没有....print("Python简易计算器--Map映射写法")
circle=input("请输入一个四则运算式子:")
if circle.find("+")!=-1:
print(circle.partition("+"),"+",circle.partition("+"),"=",*map(lambda infront,behind:infront+behind,)],)]))
if circle.find("-")!=-1:
print(circle.partition("-"),"-",circle.partition("-"),"=",*map(lambda infront,behind:infront-behind,)],)]))
if circle.find("*")!=-1:
print(circle.partition("*"),"*",circle.partition("*"),"=",*map(lambda infront,behind:infront*behind,)],)]))
if circle.find("/")!=-1:
if circle.partition("/")=="0":
print("除数不能为零...程序即将报错停止")
assert False
print(circle.partition("/"),"/",circle.partition("/"),"=",*map(lambda infront,behind:infront/behind,)],)]))
页:
[1]