下面是我的代码。它给了我一个编译错误,说尚未定义艺术家。这让我很困惑,因为艺术家是我传递的参数。
谢谢。
class Track:
def __init__(self, artist, title, album=None):
self.artist = str(artist)
self.title = str(title)
self.album = album
def __str__(self):
return self.artist + " " + self.title + " " + self.album
def set_album(self, album):
self.album = album
类专辑:def init(self,artist,title,year='',genre='',tracks=None):self.artist = str(artist) self.title = str(title) self.year = str(year ) self.genre = str(genre) self.tracks = 曲目
def __str__(self):
return self.artist + " " + self.title + " " + self.year + " " + self.genre + " " + self.tracks
def add_track(track):
self.tracks.append(track)
def music_library(曲目,专辑):
while true:
command = raw_input("Please enter a command (s, st or sa)").lower()
if "s " in command:
searchText = command.split()(1)
elif "sa " in command:
searchText = command.split()(1)
elif "st " in command:
searchText = command.split()(1)
从 mutagen.mp3 导入 os 导入 MP3 def load_library(dir):
for root, dirs, files in os.walk("."):
for filename in files:
if filename.lower().endswith(".mp3"):
fullname = os.path.join(root, filename)
print "\n%s" % fullname
try:
audio = MP3(fullname)
for key in audio:
print " %s: %s" % (key, str(audio[key]))
except:
print "Error on %s" % fullname
那是整个文件。我正在使用它运行它
蟒蛇音乐库.py