def fetchExtension(folderDir):
extensions = []
arrayOfFiles = os.listdir(folderDir)
#Fetches all the extension
for file in arrayOfFiles:
if "." in file:
extension = file.split(".")
extensions.append((file,extension[-1]))
#Returns an array of extensions
return extensions
fileExtension = fetchExtension(downloadDir)
print(fileExtension)
我正在尝试从该文件夹中获取所有扩展名和文件名。然后返回一个文件名和扩展名的数组,但是当我尝试打印该数组时,我得到一个错误
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 2152-2153: character maps to <undefined>