[英]Python indentation issue: Expected an indentation block
def process_health_case(request):
about = request.POST['about']
details = request.POST['narrative_text']
image=request.FILES['image_scan']
connection = Connection('mongodb://sbose78:PASSWORD@staff.mongohq.com:10068/BOSE')
if images:
db=connection['BOSE']
fs=gridfs.GridFS(db)
fs.put(image,filename="image_scan2")
else:
#nothing
return render_to_response('home/new_narrative.html',{ }, context_instance=RequestContext(request))
I'm getting 我越来越
expected an indented block (views.py, line 41)
And line 41 is the last line. 第41行是最后一行。
Where am I wrong? 我哪里错了?
Thanks. 谢谢。
You can't use a comment as an empty statement, you should use pass
if you want to have an explicit else that does nothing. 您不能将注释用作空语句,如果您希望拥有一个不执行任何操作的显式else,则应使用
pass
。
if images:
db=connection['BOSE']
fs=gridfs.GridFS(db)
fs.put(image,filename="image_scan2")
else:
pass
return ....
Since there's no statement, just a comment in the else
in your code, python thinks the return
is supposed to be the content of the else
and gives an intentation error. 由于没有语句,仅在代码的
else
中添加了注释,python认为return
应该是else
的内容,并给出一个意图错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.