|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- class Asl():
- def __init__(self):
- self.height=0
- self.name="海平面"
- self.status="适合人们居住生活"
- def living_condition(self,high):
- self.height=high
- if 0<self.height<1500:
- self.name="低海拔"
- self.status="适合人们居住生活"
- elif 1500<=self.height<3500:
- self.name="高海拔"
- self.status="一般人可以生活适应"
- elif 3500<=self.height<5500:
- self.name="超高海拔"
- self.status="根据个人情况而定,有些人不适应"
- elif 5500<=self.height:
- self.name="极高海拔"
- self.status="不适应人们居住生活"
- def __str__(self):
- return f"地区高度为{self.height}米,称之为{self.name},{self.status}。"
- serendipitv=Asl()
- serendipitv.living_condition(4115)
- print(serendipitv)
复制代码
这 个 程 序 代 码 ,为 什 么 报 错 呢 ?
你的缩进没有对准
- class Asl():
- def __init__(self):
- self.height=0
- self.name="海平面"
- self.status="适合人们居住生活"
- def living_condition(self,high):
- self.height=high
- if 0<self.height<1500:
- self.name="低海拔"
- self.status="适合人们居住生活"
- elif 1500<=self.height<3500:
- self.name="高海拔"
- self.status="一般人可以生活适应"
- elif 3500<=self.height<5500:
- self.name="超高海拔"
- self.status="根据个人情况而定,有些人不适应"
- elif 5500<=self.height:
- self.name="极高海拔"
- self.status="不适应人们居住生活"
- def __str__(self):
- return f"地区高度为{self.height}米,称之为{self.name},{self.status}。"
- serendipitv=Asl()
- serendipitv.living_condition(4115)
- print(serendipitv)
复制代码
|
|