# 一旦遇到第一个return,函数执行就会停止 def three(): print(1) return 2 print(3) return 22 three() print(4) ---------------------- for i in range(10): line = "" for j in range(10): if i == j: break line += "{} ".format(j) print(line) ----------------------- 魔法函数 __init__ :初始化类的新实例 Initialize a new instance of the class __new__ :创建该类的新实例 Create a new instance of the class __repr__ :定义实例表示进行调试 Define an instance representation for debugging __str__ :定义实例的用户友好表示 Define user-friendly representation of an instance class Song: def __init__(self, artist, name, year): self.artist = artist self.name = name self.year = year def __repr__(self): rep = "Artist: {}. Name: {}. Year: {}".format(self.artist, self.name, self.year) return rep def __str__(self): return "{} — {} ({})".format(self.artis...