我正在用python 3做一个提问程序,我用的是下面的代码
print ('how old are you?')
age = input ('age :')
if age < 18): print('Okay')
当我运行它时,有一条消息说
if age < (18):
^
IndentationError: unexpected indent
我该怎么办?
我不太明白下面代码的问题是什么
for stripe in [sku.value for sku in model_sheet.col(13) if str(sku.value)]:
try:
stripe = int(stripe)
except ValueError:
stripe = unicode(stripe)
for stars in [sku.value for sku in model_sheet.col(19) if str(sku.value)]:
yield HatI
当我尝试制作齿轮时(请记住,我刚开始制作齿轮),我得到了错误信息 discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.fun' raised an error: IndentationError: expected an indented block (fun.py, line 7) 齿轮的代码是; import discord
import os
from discord.ext import commands
class Fun(commands.Cog):
def setup(bot):
我是python的初学者,在学习过程中,在执行if语句时遇到了一个错误。
有人能告诉我我在代码中遗漏了什么吗?
文件"Demo_class2_Conditions.py",第8行
打印(X)
^
IndentationError:期望有一个缩进块
X=int(input('Enter the value of X:'))
Y=int(input('Enter the value of Y:'))
Z=int(input('Enter the value of Z:'))
if X > Y:
if X >
目前,我正在使用Mac终端学习Python基础知识,在定义函数时我不知道如何编写新行,因为每当我点击"Enter“时,它就会抛出一个错误。
>>> def f():
... a = 10
File "<stdin>", line 2
a = 10
^
IndentationError: expected an indented block after function definition on line 1
try:
for v in d.values():
for item in v[1:]:
if item != v[0]:
except ValueError:
raise ValueError('this is inconsistent')
我得到了以下输出-
except ValueError:
^ IndentationError:应为缩进块
有人能告诉我在这个Python代码示例中我做错了什么吗?
for i in range(len(Adapters)):
print Adapters[i]
我正在尝试列出/打印数组内容,但代码在打印命令时显示错误:IndentationError: expected an indented block
我试图编写一个登录页面,Visual说第5行有IndentationError: expected an indented block,我能做些什么来修复这个函数呢?我可以这样编码登录页面吗?
这只是为了我的练习,我是一个新的编码器。
def register_acc(x,y,z):
while True:
x = input("Enter nickname: \t")
if x.isalnum == True:
while True:
y = char(input("enter pass: \t")
我向程序中添加了一个简单的打印变量行,它给了我一个IndentationError。代码使用"print yes“行进行注释,如下所示,但当我取消注释时,我得到错误:
错误:
factors.append(yes)
^
IndentationError: unexpected indent
代码:
n = 1
x = int(raw_input("What is the number you would like largest prime factor of?"))
factors= []
checklist = []
primefactors = []
while
if len(trashed_files) == 0 :
print "No files trashed from current dir ('%s')" % os.path.realpath(os.curdir)
else :
index=raw_input("What file to restore [0..%d]: " % (len(trashed_files)-1))
if index == "*" :
for tfile in trashed_files :
我是python的新手,所以请原谅任何基本的错误。我从一个网站上获取了这段代码(它看起来相当简单),所以我认为它会起作用。基本上,我希望这个代码块打印出2015到2016年之间的所有日期。据我所知,缩进看起来没问题。我也试过调整缩进,但我没有任何运气让它工作。任何帮助都将不胜感激。
import calendar
cal = calendar.Calendar()
for year in range(2015,2016):
for month in range(1,13):
monthdays = [d for d in cal.itermonthdays(year
这是代码
GrassFilledX = GrassGenX
GrassFilledY = GrassGenY
GrassFillL = True
while GrassFillL == True:
if gx == hgx or hgx2:
while not crashed:
错误显示
while not crashed:
^
IndentationError: expected an indented block
我试着用“美丽汤”编写一个简单的脚本,它可以只需要两个信息,并且可以从一个网站生成一个SQL文件。
import mechanize
import urlparse
from bs4 import BeautifulSoup
op = mechanize.Browser()
op.open("https://www.mentalhelp.net/symptoms/")
for link in op.links():
print link.text
print urlparse.urljoin(link.base_url, link.url)
get = BeautifulSo
我得到以下缩进错误
>>> number = 35
>>> if number == 35:
print 'true'
else:
File "<pyshell#130>", line 3
else:
^
IndentationError: unindent does not match any outer indentation level
>>>
这只会在空闲时发生,而不会发生在命令行上。我在Windows XP上使用Python 2.6.4。我已经在
>>> if 5==5:
print '5'
else: print 'cat'
File "<pyshell#2>", line 3
else: print 'cat'
^
IndentationError: unindent does not match any outer indentation level
无论缩进是什么,它仍然不起作用。即使我尝试将print cat语句放在下一行,也会出现语法错误。为什么会这样呢?
这是我的密码
def count (a, e, i, o, u):
a_length = len(a);
e_length = len (e);
i_length = len (i);
o_length = len (o);
u_length = len (u);
total = 0;
for i in range (a_lenght):
if(a[i] == u[0]):
end = i + u_length;
if (a[i:end] == u):
total +=1
我正在遵循Michael Halls-Moore算法交易一书,并对代码有一些问题。当我将代码粘贴到python中时,我得到了一堆错误。
我是不是遗漏了什么,因为它和书中写的一模一样?
from __future__ import print_function
from numpy import cumsum, log, polyfit, sqrt, std, subtract
from numpy.random import randn
def hurst(ts):
"""Returns the Hurst Exponent of the time ser
我做了一个小程序来学习这个基础,我不明白为什么它不能工作,所以你能帮我解释一下我的错误吗?欢迎每一个答案
import random
def gessing_game():
t = 0
r = random.randint(0,100)
print(r)
y = int(input("Please choose your number"))
while y != r:
t = t + 1
print("You have made",t,"attempts")
if y > r:
print("T
RAM=open('/root/arg2', 'r').read()
if RAM=="":
try:
if not sys.argv[2]=="":
f = open("/root/arg2","a")
f.write(sys.argv[2])
f.close()
if float(RAM) > 4096:
os.system(