python check file type

How to get the type of a file with python? Stack Overflow. You can try using the file command, executed via subprocess. result = subprocess.check_output ( ['file', '/path/to/allcfgconv']) The resulting string is a bit verbose; you'll have to parse the file type from it yourself. Share answered Aug 6, 2021 at 12:47 chepner 463k.

How to get the type of a file with python? Stack Overflow
How to get the type of a file with python? Stack Overflow from i.stack.imgur.com

Magic (mime = True) mimetype = mime. from_file ('example.py') print "example.py: ", mimetype mimetype = mime. from_file ('License.pdf') print "License.pdf: ", mimetype mimetype = mime..

0 komentar