python意外缩进引发逻辑错误,Python IndentationError:意外缩进

Here is my code ... I am getting indentation error but i don't know why it occurs.

->

# loop

while d <= end_date:

# print d.strftime("%Y%m%d")

fecha = d.strftime("%Y%m%d")

# set url

url = 'http://www.wpemergencia.omie.es//datosPub/marginalpdbc/marginalpdbc_' + fecha + '.1'

# Descargamos fichero

response = urllib2.urlopen(url)

# Abrimos fichero

output = open(fname,'wb')

# Escribimos fichero

output.write(response.read())

# Cerramos y guardamos fichero

output.close()

# fecha++

d += delta

解决方案

Run your program with

python -t script.py

This will warn you if you have mixed tabs and spaces.

On *nix systems, you can see where the tabs are by running

cat -A script.py

and you can automatically convert tabs to 4 spaces with the command

expand -t 4 script.py > fixed_script.py

PS. Be sure to use a programming editor (e.g. emacs, vim), not a word processor, when programming. You won't get this problem with a programming editor.

PPS. For emacs users, M-x whitespace-mode will show the same info as cat -A from within an emacs buffer!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值