我多次听说这样的编码不是最理想的:
if weapon == "sword": print("Knight") elif weapon == "katana": print("Samurai") elif weapon == "axe": print("Viking")
如何以最佳方式编写此类代码?
python if-statement python-3.x
if-statement ×1
python ×1
python-3.x ×1