mimetypes.guess_type()の挙動はOS依存だよ

なんだこれゎ。

mimetypes.guess_type() でどのmimetypeが返ってくるかは動作している環境のOSに依存する様子。
そのため、たとえば hogehoge.csv というファイルを引数に与えたとき、
Windowsでは application/vnd.ms-excel が返り、Linuxでは text/csv が返る。
動作環境を変えたときにこれ使ってるとハマるので注意。

Windows

>>> import platform
>>> platform.platform()
'Windows-10-10.0.17763-SP0'

>>> import mimetypes
>>> mimetypes.guess_type('hogehoge.csv')
('application/vnd.ms-excel', None)

>>> mimetypes.guess_type('hogehoge.xlsx')
('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', None)

Linux

>>> import platform
>>> platform.platform()
'Linux-4.9.125-linuxkit-x86_64-with-debian-9.4'

>>> import mimetypes
>>> mimetypes.guess_type('hogehoge.csv')
('text/csv', None)

>>> mimetypes.guess_type('hogehoge.xlsx')
('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', None)

ただ text/csv を取りたかっただけなのに。。。
実用的な関数でないなぁ