我试图在python函数中生成一个html复选框。这是我的密码
import HTML
def CreateEvent(str):
"This prints a passed string into this function"
print str;
return;
CreateEvent ('''
content-type: text/html
<html>
<head>
<title> the list of all possible events that can be notified by our system </title>
</head>
<body>
<form>
<input type="checkbox" name="tsunami" value="tsunami">tsunami<br>
<input type="checkbox" name="earthquake" value="earthquake">earthquake<br>
<input type="checkbox" name="volcano" value="volcano">volcano<br>
<input type="checkbox" name="hurricane" value="hurricane">hurricane<br>
<input type="checkbox" name="sinkholes" value="sinkholes">sinkholes<br>
<input type="checkbox" name="tornado" value="tornado">tornado<br>
<input type="checkbox" name="landslide" value="landslide">landslide<br>
<input type="checkbox" name="downburst" value="downburst">downburst<br>
</form>
<input type="submit" value="Submit">
</body>
</html>
''')
但是当我试图编译它时,它给出了一个语法错误:需要一个预期的块。请告诉我如何解决这个问题。在
你在评论中没有缩进。在
注意:注释是}
"""
而不是{一个好主意是安装
^{pr2}$pep8
python库并执行如果有问题的话
您需要正确缩进:
…这应该是一个三重引号的字符串as per PEP8
…不要在行尾加分号
错误消息的名称将提示您问题所在。在
您没有正确地缩进,因此得到“syntaxError:expected anindented块”。在
另外,在Python中,行不以分号结尾,这不是C#。在
我建议读一个基本的Python guide和一个Python tutorial
相关问题 更多 >
编程相关推荐