Я пытаюсь выполнить задачу, но испытываю некоторые трудности. Может кто-то прямо указывал мне на следующее:
#This worked for me
myFormats = {'audio': ('.wav', '.wma', '.mp3'), 'video': ('.mpg', '.mp4', '.mpeg')}
myFile = '5DeadlyVenoms.mp3'
f_exten = (x for x in myFormats['audio'] + myFormats['video'] if myFile.endswith(x))
extension = f_exten.next()
Использование следующего привело к этой ошибке:
myFormats = {'audio': {'.wav', '.wma', '.mp3'}, 'video': {'.avi', '.mpg', '.mp4', '.mpeg'}}
Traceback:
Traceback (most recent call last):
File "C:\Users\GVRSQA004\Desktop\udCombo.py", line 65, in fileFormats
f_exten = (x for x in myFormats['audio'] + myFormats['video'] if myFile.endswith(x))
TypeError: unsupported operand type(s) for +: 'set' and 'set'
Traceback (most recent call last):
File "C:\Users\GVRSQA004\Desktop\udCombo.py", line 65, in fileFormats
f_exten = (x for x in myFormats['audio'] + myFormats['video'] if myFile.endswith(x))
TypeError: unsupported operand type(s) for +: 'set' and 'set'