1.

class Foo(object):
def __init__(self,name,price,period):
self.name=name
self.price=price
self.period=period
def __repr__(self):
return 'Foo:%s--%s--%s'%(self.name,self.price,self.price)
# def __str__(self):
# return 'Foo:%s--%s'%(self.name,self.price)
class Son(Foo):
# def func(self):
# pass
# def __repr__(self):
# return 'Son:%s--%s--%s'%(self.name,self.price,self.price)
# def __str__(self):
# return 'Son:%s--%s'%(self.name,self.price)
alex = Son('lemon',13.5,'一季度')
print(alex)
#这时运行时会飘红出错!!

  

而我在派生类中建立了函数,结果就运行出来了。

class Foo(object):
def __init__(self,name,price,period):
self.name=name
self.price=price
self.period=period
def __repr__(self):
return 'Foo:%s--%s--%s'%(self.name,self.price,self.price)
# def __str__(self):
# return 'Foo:%s--%s'%(self.name,self.price)
class Son(Foo):
def func(self):
pass
# def __repr__(self):
# return 'Son:%s--%s--%s'%(self.name,self.price,self.price)
# def __str__(self):
# return 'Son:%s--%s'%(self.name,self.price)
alex = Son('lemon',13.5,'一季度')
print(alex)

  

IndentationError: expected an indented block 在继承中出现的问题:未完的更多相关文章

  1. python中IndentationError: expected an indented block错误的解决方法

    IndentationError: expected an indented block 翻译为IndentationError:预期的缩进块 解决方法:有冒号的下一行要缩进,该缩进就缩进

  2. python 中出现 “IndentationError: expected an indented block” 问题

    python 学习 在定义Python函数的时候如下 >>>def hello() . . .print "hello" 这样会报错的,报错如下: Indenta ...

  3. [转]python问题:IndentationError:expected an indented block错误解决

    分类: python学习笔记2012-07-07 17:59 28433人阅读 评论(4) 收藏 举报 python语言 原文地址:http://hi.baidu.com/delinx/item/17 ...

  4. python问题:IndentationError:expected an indented block错误解决《转》

    python问题:IndentationError:expected an indented block错误解决 标签: python语言 2012-07-07 17:59 125145人阅读 评论( ...

  5. python问题:IndentationError:expected an indented block错误解决

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

  6. IndentationError : expected an indented block

    IndentationError:在python的条件语句出现 expected an indented block问题 是指缩进问题,比如for循环里面的print前面需要四个空格. Python语 ...

  7. IndentationError:expected an indented block错误解决

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

  8. Python问题1:IndentationError:expected an indented block

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

  9. python问题:IndentationError:expected an indented block

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

随机推荐

  1. eclipse开发android入门学习

    1.device窗体            查看android执行情况的窗体和DDMS内容一致 2.android.bat             在adb路径下执行adb操作,实现android系统 ...

  2. 第三部分:Android 应用程序接口指南---第二节:UI---第三章 菜单

    第3章 菜单 在许多不同类型的应用中,菜单通常是一种用户界面组件.为了提供给用户提供熟悉且一致的体验,你需要使用菜单API来展示用户动作和你Activity中的其他选项. 从安卓3.0系统(API l ...

  3. Atitit 错误处理机制:(1)静默模式(2)警告模式 (3)异常模式

    Atitit 错误处理机制:(1)静默模式(2)警告模式 (3)异常模式       三.     PDO的错误处理机制: (1)静默模式 默认情况下与mysql处理方式一致,不现实错误信息(静默模式 ...

  4. 物联网架构成长之路(9)-双机热备Keepalived了解

    1. 前言 负载均衡LB,高可用HA,这一小结主要讲双机热备方案保证高可用.这里选择Keepalived作为双机热备方案,下面就对具体的配置进行了解.2. 下载Keepalived wget http ...

  5. 【iCore1S 双核心板_ARM】例程十:SYSTICK定时器实验——定时点亮LED

    实验原理: 通过STM32的三个GPIO口驱动三色LED的三个通道,设定GPIO为推挽输出,采用 灌电流的方式与LED连接,输出高电平LED灭,输出低电平LED亮,通过系统定时器实现 1s定时,每秒变 ...

  6. PyCharm设置改变字体大小的快捷键

    File->Settings 在搜索框搜索increase 点击Increase Font Size(增大字体)右键选择Add Mouse Shortcut 然后按Ctrl并且鼠标滚轮往上滚. ...

  7. java 全组合 与全排列

    一.全组合 public static void Combination( ) { /*基本思路:求全组合,则假设原有元素n个,则最终组合结果是2^n个.原因是: * 用位操作方法:假设元素原本有:a ...

  8. Linux监控平台介绍 zabbix监控介绍 安装zabbix 忘记Admin密码如何做

  9. Android四大组件之——Activity(一)定义、状态和后退栈(图文详解)

    什么是Activity 关键字:应用组件.四大组件.用户界面,交互. An Activity is an application component that provides a screen wi ...

  10. python中用修饰器进行异常日志记录

    当脚本中需要进行的的相同的异常操作很多的时候,可以用修饰器来简化代码.比如我需要记录抛出的异常: 在log_exception.py文件中, import functools import loggi ...