开发者

How do i correct a files extension?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜