**已关闭。**此问题为not reproducible or was caused by typos。目前不接受答案。
这个问题是由一个打字错误或一个无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
9小时前关门了。
Improve this question
希望有一个输入变量来问一个问题,有很多合适的真语句,但根据用户输入的内容给出不同的答案。我目前的代码与下面的类似,但不能正常工作。
我只想打印一个或另一个语句。我还想使这个代码适合许多其他的答案,如“也许你有什么?”“有便宜的东西吗?”“我想要一些随机的!”
我的代码如下所示:
第一个
2条答案
按热度按时间moiiocjp1#
从你的问题中,我理解的是,你需要一个问题列表来让用户回答。在Python 3.10中,可以使用
match
和case
关键字以更好的方式来完成,就像reference中提到的那样。我已经实现了一个示例,以供你理解,沿着提供了输出。编码:
输出量:
iezvtpos2#
Python使用
==
来检查字符串条件匹配,例如: