I started programming in Python a couple of days ago and I have a problem I couldn't solve yet. I want to correct a files file extension by guessing its mimetype. I tried this:
new_file_name = mimetypes.guess_extension(mimetypes.guess_type开发者_如何转开发(file_name)))
os.rename(file_name, new_file_name)
Why doesnt it work?
mimetypes
uses the existing extension to guess the file type. Use magic
instead to examine the contents.
精彩评论