Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #以下代码段将展示如何编写一个不使用 if-else 条件的简单计算器。
  2.  
  3. import operator
  4. action = {
  5. "+": operator.add,
  6. "-": operator.sub,
  7. "/": operator.truediv,
  8. "*": operator.mul,
  9. "**": pow
  10. }
  11. print(action[ - ](50, 25)) # 25
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement