Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
特殊的eyed3类型变成python';s型_Python_Python 3.x_Operating System_Eyed3 - Fatal编程技术网

特殊的eyed3类型变成python';s型

特殊的eyed3类型变成python';s型,python,python-3.x,operating-system,eyed3,Python,Python 3.x,Operating System,Eyed3,我已经编写了一个小脚本,将我所有的.flac文件从dap移动到Artister子文件夹,以便从计算机上轻松访问。我在Ubuntu上使用了python3和诸如eyed3和os之类的libs。而且它在近30首歌曲(2位艺术家)中表现良好。 下面是代码: 导入操作系统 导入eyed3 os.chdir(“/home/user/Music”) cwd=os.getcwd() #打印当前目录 打印(“当前工作目录为:”,cwd) listOfFiles=os.listdir() 艺术家=[] #打印(列表

我已经编写了一个小脚本,将我所有的.flac文件从dap移动到Artister子文件夹,以便从计算机上轻松访问。我在Ubuntu上使用了python3和诸如eyed3和os之类的libs。而且它在近30首歌曲(2位艺术家)中表现良好。 下面是代码:

导入操作系统
导入eyed3
os.chdir(“/home/user/Music”)
cwd=os.getcwd()
#打印当前目录
打印(“当前工作目录为:”,cwd)
listOfFiles=os.listdir()
艺术家=[]
#打印(列表文件)
尝试:
对于listOfFiles中的文件:
aFile=eyed3.load(文件)
艺术家=aFile.tag.artist
如果艺术家不在某个位置:
艺术家。附加(艺术家)
os.mkdir(艺术家)
重命名(cwd+'/'+文件,cwd+'/'+艺术家+'/'+文件)
除:
打印(“非文件”)
印刷品(艺术家)
它创建了两个文件夹。 但当我试图在我的Windows PC上运行此脚本时,它抛出了一个异常并打印“不是文件”。 以下是不带try/except的控制台输出:

Traceback (most recent call last):
  File "D:\GitHub\Song-Sorter\main.py", line 21, in <module>
    artist = aFile.tag.artist
AttributeError: 'NoneType' object has no attribute 'tag'
其输出为:


有什么问题?无法找到解决方案。我在图书馆的mp3部分测试了这个脚本,效果很好。然后我尝试了flac部分,但它不起作用,因为eyed3只适用于mp3。所以我建议使用诱变剂库

始终将完整的错误消息(从单词“Traceback”开始)作为文本(而不是截图)进行讨论(而不是评论)。还有其他有用的信息。可能某些文件没有关于艺术家的信息-您应该在其他程序中检查此文件。