1
此脚本不会传递第一个if表达式! 如果用户输入DD或F,那么脚本就像if状态为真。Python如果表达式在原始输入中无法正常工作
choice = raw_input("Cup size for bra: D, DD, or F: ")
if choice == "D" or "d":
band_length = raw_input("Please enter the bra band length for your D size breasts: ")
D_Statistics(band_length)
elif choice == "DD" or "dd":
band_length = raw_input("Please enter the bra band length for your DD size breasts: ")
DD_statistics(band_length)
elif choice == "F" or "f":
band_length = raw_input("Please enter the bra band length for your F size breasts: ")
F_statistics(band_length)
choice.lower()或choice.upper()然后测试一次。 – 2014-11-08 03:35:00
@RafaelBarros我不认为这将提供很多优势,调用函数将永远更昂贵,使用文字 – 2014-11-08 03:37:47
我明白你的观点,我同意。另外:更昂贵。 – 2014-11-08 03:41:14