小编MBe*_*Bee的帖子

如何避免 If 语句的围墙?

我多次听说这样的编码不是最理想的:

if weapon == "sword":
 print("Knight") 
elif weapon == "katana":
 print("Samurai") 
elif weapon == "axe":
 print("Viking")
Run Code Online (Sandbox Code Playgroud)

如何以最佳方式编写此类代码?

python if-statement python-3.x

0
推荐指数
1
解决办法
112
查看次数

标签 统计

if-statement ×1

python ×1

python-3.x ×1