python3 类 变量定义 __刚开始学习python,定义了一个类,带了三个属性的变量,后面的输入输出不太对,求指点python...

classAddressList():def__init__(self,name,age,qq):self.name=nameself.age=ageself.qq=qqdefgetList(self):print"Thenameofyourresultis:",self.nameprint"Theageofyourresultis:",...

class AddressList():

def __init__(self,name,age,qq):

self.name=name

self.age=age

self.qq=qq

def getList(self):

print "The name of your result is :",self.name

print "The age of your result is :",self.age

print "The qq of your result is :",self.qq

return

def searchByname(name):

if list.name==name:

print list.getList()

else:

return ("The people does't exit")

def searchByage(age):

if list.age==age:

print list.getList()

else:

print ("This age of people does't exit")

def searchByqq(qq):

if list.qq==qq:

print list.getList()

else:

print ("The qq does't exit")

if __name__ =="__main__":

name=raw_input("Please input the name:")

age=raw_input("Please input the age:")

qq=raw_input("Please input the qq:")

list = AddressList(name,age,qq)

print list.getList()

method=raw_input("Which element do you want search by ? :")

print method

if (method==name):

name = raw_input("Input your search name:")

searchByname(name)

elif method==age:

name = raw_input("Input your search age:")

searchByage(name)

elif method==qq:

name = raw_input("Input your search qq:")

searchByqq(name)

为什么会多出一个None的,去掉getList函数里面最后一个return还是会出现,还有最后输入查找元素内容之后,为什么程序就断开了?,

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值