“意外缩进”使用notepad ++创建django函数时出错 [英] "unexpected indent" error when using notepad++ for creating django function

查看:122
本文介绍了“意外缩进”使用notepad ++创建django函数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注这本书,使用notepad ++学习django,有趣的是,当我键入功能对于以下脚本使用notepad ++:

I am following this book to learn django using notepad++, something interesting happens, when I type the function using notepad++ for the following script:

def current_datetime(request):
    now = datetime.datetime.now()
    html = "<html><body>It is now %s.</body></html>" % now
    return HttpResponse(html)

它给我一个这样的错误: p>

It gives me an error like this:

IndentationError at /time/

('unexpected indent', ('M:\\DjangoStack\\projects\\beta_01\\..\\beta_01\\hello_world\\views.py', 12, 1, '\thtml = "<html>"\n'))

但是当我直接从书中粘贴它,这是可以的。我不知道为什么,我应该在记事本++中做一些设置?谢谢。

But when I paste it directly from the book, it is OK. I wonder why, should I do some settings in notepad++? Thanks.

我使用 4个空格键在记事本++中创建缩进,我试过 1选项卡,似乎问题是固定的

I use 4 space bars to create the indent in notepad++, I tried 1 tab and seems the problem is fixed

推荐答案

设置 - >首选项 - >语言菜单/选项卡设置 - >按空格替换

Settings->Preferences->Language Menu/Tab Settings->"Replace by space"

这篇关于“意外缩进”使用notepad ++创建django函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆