from django.db import models
class Category(models.Model):
title = models.CharField(max_length=250)
slug = models.SlugField(unique=True)
description = models.TextField()
class Meta:
verbose_name_plural = "Categories"
def __unicode__(self):
return self.title
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
Run Code Online (Sandbox Code Playgroud)verbose_name_plural = "Categories" ^ IndentationError: expected an indented block
我使用gedit使用空格作为选项卡的选项(也试图改变标签宽度)..我几乎可以肯定代码是正确的..但是间距和标签的一些问题..
是否可以在源Perl文件的顶部放置注释,以使Emacs在同一文件中遵守4空格缩进规则,而不管在其中定义的默认缩进规则.emacs?
我发现自己用不同的缩进编辑Perl文件,一些2间距,一些4间距,我希望Emacs自动遵循文件本身描述的缩进规则,而不是每次都要更改配置.
所有这些都cperl-mode用于Perl编辑(http://www.emacswiki.org/emacs/CPerlMode).
我尝试在此示例perl脚本的末尾添加以下注释:
#!/usr/bin/perl
my @a = (1,2,3,4,5,6);
for my $e (@a) {
print "$e\n";
}
# Local variables:
# perl-indent-level: 4
# End:
Run Code Online (Sandbox Code Playgroud)
但它仍然使用缩进级别2.也许原因是因为它没有覆盖.emacs设置?
我只是用vim来编辑一个javascript文件.我在vim中的缩进设置如下:
当我编辑文件的一部分时,在vim中看起来好像缩进是正确的:
但是,在SourceTree和Sublime Text中,缩进不正确:
SourceTree:
崇高文字:
任何人都可以向我解释为什么会发生这种情况以及我如何解决这个问题?我也很好奇,实际上,这是文件状态的"真实"表示.
当我运行以下代码时,出现错误:“IndentationError:unident 与任何外部缩进级别不匹配”。
我究竟做错了什么?我在下面包含了我的代码以供参考:
file=open('csquetionseasy.txt','r')
print(file.read(432))
answersinputeasy=input('enter the letter responding to the correct answer for all 3 questions e.g. BBB')
if answersinputeasy==('BAA'):
print('you got 3/3!')
else:
if answersinputeasy==('BAB'):
print('2/3!')
else:
if answersinputeasy==('BBB'):
print('1/3!')
else:
if answersinputeasy==('ABB'):
print('0/3!')
else:
if answersinputeasy==('AAB'):
print('1/3!')
else:
if answersinputeasy==('AAA'):
print('2/3!')
else:
if answersinputeasy==('ABA'):
print('1/3!')
Run Code Online (Sandbox Code Playgroud) 基本思想是写这样的一行:
url = 'https://{host}?key={key}&lang={lang}&text='.format(**data) + '&text='.join(words)
Run Code Online (Sandbox Code Playgroud)
想要用PEP 8样式重写它,所以写了这样的代码:
url = 'https://{host}?key={key}&lang={lang}&text='.format(**data) \
+ '&text='.join(words)
Run Code Online (Sandbox Code Playgroud)
其中哪一项是对的?
如果两者都不行,我想听听为什么,然后看看你会怎么写。
显然,这:
def f():
pass
# maybe the function is over
pass # oh wait, it's not
f()
Run Code Online (Sandbox Code Playgroud)
是有效的语法,而这不是:
def f():
pass
''' maybe the function is over '''
pass # oh wait, it's not
f()
Run Code Online (Sandbox Code Playgroud)
这对我来说是一个巨大的惊喜。所以我的问题是:
我的 HTML 代码如下所示:
<style type="text/css">
<!--
td.indent {text-indent:10mm; }
//-->
</style>
Run Code Online (Sandbox Code Playgroud)
[...]
<table>
<tr>
<td class="indent"> Long line of text </td>
<td class="indent"> Some other text </td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
表中的输出文本按预期缩进:
Long line of text
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用以下命令添加换行符时<br>:
<td class="indent"> Long line of<br> text </td>
Run Code Online (Sandbox Code Playgroud)
<br>仅缩进前面的部分:
Long line of
text
Run Code Online (Sandbox Code Playgroud)
我怎样才能让输出看起来像这样?
Long line of
text
Run Code Online (Sandbox Code Playgroud) import os
import sys, urllib2, urllib
import re
import time
from threading import Thread
class testit(Thread):
def __init__ (self):
Thread.__init__(self)
def run(self):
url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php'
data = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req = urllib2.Request(url)
fd = urllib2.urlopen(req, data)
<TAB>fd.close()
<TAB>"""while 1:
data = fd.read(1024)
if not len(data):
break
sys.stdout.write(data)"""
url2 = 'http://games.espnstar.asia/the-greatest-odi/post_perc.php'
data2 = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req2 = urllib2.Request(url2)
fd2 = urllib2.urlopen(req2, data2)
<TAB>#prints current votes
while 1:
data2 = fd2.read(1024)
if not len(data2):
break
sys.stdout.write(data2)
<TAB>fd2.close()
print time.ctime()
print " ending …Run Code Online (Sandbox Code Playgroud) 这段代码有什么问题,在你问我之前用youtube视频和简短的教程做了这一切.非常感谢有人可以帮我编码,在这种情况下只需要我的Skype,我会加你,我需要这样做!:).
在第253行左右,它说需要"预期的缩进块"我真的不知道该怎么做.
import pygame, sys, time, random, Globals
from pygame.locals import *
pygame.init()
pygame.mixer.init(frequency=22050, size=-16, channels=10, buffer=4096)
#Classes
class MenuButton(pygame.sprite.Sprite):
def __init__(self, image, image_dem, x, y):
self.image = pygame.image.load(image[0]).convert_alpha()
self.image_over = pygame.image.load(image[1]).convert_alpha()
self.image_dem = image_dem
self.x = x
self.y = y
self.rect = pygame.Rect(self.x, self.y, self.image_dem[0], self.image_dem[1])
def setXY(x, y):
self.x = x
self.y = y
def setImage(image, dem):
self.image = pygame.image.load(image[0]).convert_alpha()
self.image_over = pygame.image.load(image[1]).convert_alpha()
self.image_dem = dem
class Sprite(pygame.sprite.Sprite):
def __init__(self, image, image_dem, x, y):
self.image = pygame.image.load(image).convert_alpha()
self.image_dem …Run Code Online (Sandbox Code Playgroud) indentation ×10
python ×6
comments ×1
css ×1
django ×1
emacs ×1
html ×1
if-statement ×1
objective-c ×1
pep8 ×1
perl ×1
pygame ×1
syntax-error ×1
vim ×1
whitespace ×1