Home
Sign Up
Sign In
推荐学习书目
›
Learn Python the Hard Way
Python Sites
›
PyPI
- Python Package Index
›
http://diveintopython.org/toc/index.html
›
Pocoo
值得关注的项目
›
PyPy
›
Celery
›
Jinja2
›
Read the Docs
›
gevent
›
pyenv
›
virtualenv
›
Stackless Python
›
Beautiful Soup
›
结巴中文分词
›
Green Unicorn
›
Sentry
›
Shovel
›
Pyflakes
›
pytest
Python 编程
›
pep8 Checker
Styles
›
PEP 8
›
Google Python Style Guide
›
Code Style from The Hitchhiker's Guide
V2EX
›
Python
python 如果根据二进制图片数据得到图片类型?
sdjl
·
Jan 6, 2013
· 4614 views
This topic created in 5054 days ago, the information mentioned may be changed or developed.
比如有d变量保存了post到服务器的二进制图片, 服务器需要检测是否为图片以及图片类型
除了使用magic库以外 还有什么办法? 比如用mimetypes?
图片
二进制
服务器
5 replies
•
1970-01-01 08:00:00 +08:00
Livid
MOD
PRO
Jan 6, 2013
1
man file
cute
Jan 6, 2013
2
2
import imghdr
imgtype = imghdr.what('/tmp/bass.gif')
imgtype = imghdr.what(None, data)
luztak
Jan 6, 2013
3
89 50 4e 47 0d 0a 1a 0a
png文件头
这两天看这个看得头疼
sdjl
OP
Jan 6, 2013
4
@
cute
imghdr.what(None, data) 正解! 感谢
yemoluo
Jan 6, 2013
5
看这个:
http://mimesniff.spec.whatwg.org/
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
2123 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 29ms ·
UTC 00:44
·
PVG 08:44
·
LAX 16:44
·
JFK 19:44
♥ Do have faith in what you're doing.
❯