def unlock(content):
content = content.split("|")
string = []
for i in content:
if i == '渋':
i = 'C'
string.append(i)
elif i == '哋':
i = "D"
string.append(i)
elif i == '榆':
i = "U"
string.append(i)
elif i == '戼':
i = ":"
string.append(i)
elif i == '筻':
i = "\\"
string.append(i)
elif i == '槇':
i = "."
string.append(i)
else:
pass
if i == '誒':
i = "a"
string.append(i)
elif i == '荸':
i = "b"
string.append(i)
elif i == '罒':
i = "c"
string.append(i)
elif i == '籴':
i = "d"
string.append(i)
elif i == '懿':
i = "e"
string.append(i)
elif i == '諨':
i = "f"
string.append(i)
elif i == '嵇':
i = "g"
string.append(i)
elif i == '篪':
i = "h"
string.append(i)
elif i == '嗳':
i = "i"
string.append(i)
elif i == '尐':
i = "j"
string.append(i)
elif i == '尅':
i = "k"
string.append(i)
elif i == '歐':
i = "l"
string.append(i)
elif i == '尛':
i = "m"
string.append(i)
elif i == '峎':
i = "n"
string.append(i)
elif i == '鏂':
i = "o"
string.append(i)
elif i == '疋':
i = "p"
string.append(i)
elif i == '窟':
i = "q"
string.append(i)
elif i == '嬭':
i = "r"
string.append(i)
elif i == '噝':
i = "s"
string.append(i)
elif i == '悐':
i = "t"
string.append(i)
elif i == '肀':
i = "u"
string.append(i)
elif i == '徫':
i = "v"
string.append(i)
elif i == '':
i = "w"
string.append(i)
elif i == '薖':
i = "x"
string.append(i)
elif i == '韤':
i = "y"
string.append(i)
elif i == '榟':
i = "z"
string.append(i)
else:
pass
if type(string) == list:
return string
else:
return 'wrong'
这段代码在使用返回值时报错:
Traceback (most recent call last):
File "C:\Users\惠普\Desktop\music- player\music.py", line 204, in <module>
main()
File "C:\Users\惠普\Desktop\music- player\music.py", line 58, in main
f, name = get_filelist(path) # 遍历文件夹
TypeError: cannot unpack non-iterable NoneType object
函数get_filelist函数是这样的:
ef get_filelist(path):
"""
定义函数:用于遍历文件
"""
Filelist = []
name_list_gobal = []
for home, dirs, files in os.walk(path):
for filename in files:
# 文件名列表,包含完整路径
Filelist.append(os.path.join(home, filename))
# 文件名列表,只包含文件名
name_list_gobal.append(filename)
return Filelist, name_list_gobal