小编Oug*_*ghh的帖子

打印时Python"ValueError:不完整格式"("stuff%"%"thingy")

我对此代码的目标是,当您输入一定数量时,您将根据键入的内容打印数字和其他输出.出于某种原因,我在这里给出了错误"ValueError:incomplete format".它与%有关.错误意味着什么,我该如何解决?谢谢!

variable = "Blah"
variable2 = "Blahblah"

text = raw_input("Type some stuff: ")

if "1" in text:
    print ("One %" % variable)
elif "2" in text:
    print ("Two %" % variable2)
Run Code Online (Sandbox Code Playgroud)

python string format

8
推荐指数
2
解决办法
2万
查看次数

如何查找列表的一部分是否在str中

我正在努力做一个审查员.而不是做

if curseword in typed or curseword2 in typed or curseword3 typed:
    print "No cursing! It's not nice!"
Run Code Online (Sandbox Code Playgroud)

我想这样做,以便我可以有一个包含所有单词的列表,并且可以检查这些单词是否在列表中.注意:如果你使用"if any ..."代码,使用while循环,它有太多的输出要处理.

python loops

-3
推荐指数
1
解决办法
113
查看次数

标签 统计

python ×2

format ×1

loops ×1

string ×1