在终端输出如下信息,(两种以上方法)
第一种
class person: def kanchai(): print("小明,10岁,男,上山去砍柴") def kaiche(): print("小明,10岁,男,开车去东北") def dayouxi(): print("小明,10岁,男,最爱打游戏") no1 = person.kanchai() no2 = person.kaiche() no3 = person.dayouxi() print("\n") def main(): print("老李,90岁,男,上山去砍柴") print("老李,90岁,男,开车去东北") print("老李,90岁,男,最爱打游戏") main()
第二种
s1=["小明","老李"] s2=["10岁","90岁"] s3=["男"] s4=["上山去砍柴","开车去东北","最爱打游戏"] for i in range(3): print("{},{},{},{}".format(s1[0],s2[0],s3[0],s4[i])) print("\n") for k in range(3): print("{},{},{},{}".format(s1[1],s2[1],s3[0],s4[k]))