(官方)libmagic python绑定
file-magic的Python项目详细描述
file-magic
:python绑定
这个库是指向libmagic
的python cTypes接口。
安装
您可以使用以下命令安装file-magic
:
python setup.py install
# or
easy_install .
# or
pip install file-magic
使用
import magic
detected = magic.detect_from_filename('magic.py')
print 'Detected MIME type: {}'.format(detected.mime_type)
print 'Detected encoding: {}'.format(detected.encoding)
print 'Detected file type name: {}'.format(detected.name)
开发/贡献
运行测试:
python setup.py test