如何在python3脚本中为字符串指定模式?

2024-10-02 20:43:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在python脚本中为我的字符串提供一个模式。 我的意思是这样的:

x = "hello" + anyString

注意:这个anyString可以是任何东西,甚至什么都不是

更新:
在这段代码中,我想在字符串的末尾键入任何内容并得到相同的结果

userCommand = input("you> ")
if userCommand == "hello":
   print("hi!")

结果:

you> hello
hi!

当我在hello之后键入其他内容时,我希望得到相同的结果,比如:hello!


Tags: 字符串代码脚本you内容helloinput键入