【问题标题】:how do i detect if a peice of text was included in a input() line? **PYTHON**我如何检测输入()行中是否包含一段文本? **PYTHON**
【发布时间】:2021-05-09 21:54:45
【问题描述】:

蟒蛇

我太难了,请帮帮我,

如果我这样做了就说

dad = input(is your dad round or a square? )

并输入“我爸爸是圆的” 我想要它做什么检测它是否包括 我试过了

if dad includes "round"

但那不存在

注意,我知道我是否知道

if dad == "in my dad is round":

但我想看看它是否包含它而不是它是否有意义。

【问题讨论】:

  • 你使用了多少个不同版本的 Python?
  • dad = input(is your dad round or a square? ) 不是有效的 Python。

标签: windows-7 python-3.8


【解决方案1】:

你只需使用:

dad = input("is your dad round or a square?")
if "round" in dad:
# Do Something

【讨论】:

    【解决方案2】:

    正确的想法,错误的语法:

    if "round" in dad:
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-08
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 2011-12-15
      • 1970-01-01
      • 2016-07-27
      • 2021-08-18
      相关资源
      最近更新 更多