无返回值如何去掉这个NOne
这是global设置全局变量没有起到作用吗
不太明白你的意思,如果不想打印那个None,你不调用print函数就行了。
想用,不想要返回值
18行代码变成a.candan()
大佬,麻烦再看一下
@九九——文君: 你把你的代码复制一下沾出来,你都写的是什么鬼
@小小咸鱼YwY: class menu_caidan:
number = [1, 2, 3]
Name = ["番茄炒蛋", "红烧鲫鱼", "炒土豆丝"]
price = [22, 44, 13]
attribute = ["编号", "名称", "价格"]
def candan(self):
global number,Name,price,attribute
for at in attribute:
print(at , end=" ")
print(" ")
for i in number:
menu_a=[number[i-1],Name[i-1],price[i-1]]
for a in menu_a:
print(a , end=" ")
print("\t")
a=menu_caidan()
a.candan()
@九九——文君:
class menu_caidan:
number = [1, 2, 3]
Name = ["番茄炒蛋", "红烧鲫鱼", "炒土豆丝"]
price = [22, 44, 13]
attribute = ["编号", "名称", "价格"]
def candan(self):
for at in self.attribute:
print(at , end=" ")
print(" ")
for i in self.number:
menu_a=[self.number[i-1],self.Name[i-1],self.price[i-1]]
for a in menu_a:
print(a , end=" ")
print("\t")
a=menu_caidan()
a.candan()
@小小咸鱼YwY:
对的对的,不过为什么不可以用 global 啊
@九九——文君: 先去学基础吧