推荐学习书目
› 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
fxxkgw
V2EX  ›  Python

Python 如何处理 mysql 的 varbinary 类型

  •  
  •   fxxkgw · Apr 23, 2020 · 1960 views
    This topic created in 2348 days ago, the information mentioned may be changed or developed.

    数据库准备存储 ipv6 地址,设置的类型为 varbinary ( 16 )
    在 mysql 的终端可以通过 INET6_ATON (“ipv6”)方法将字符串类型的 ipv6 地址插入数据库 ,然后可以通过 INET6_NTOA ()方法把 varbinary 类型的 ipv6 地址转化为字符串类型。

    现在我在终端通过 insert into table(ip) values(INET6_ATON('fdfe::5a55:caff:fefa:9089'));方法插入了一条 ipv6 地址,通过 python 的 mysql 处理模块,拿到的返回值是:\xfd\xfe\x00\x00\x00\x00\x00\x00ZU\xca\xff\xfe\xfa\x90\x89

    如何将这条数据转为为可读性更好的 fdfe::5a55:caff:fefa:9089 这种字符串呢?用什么库或者方法实现呢?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4872 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 01:15 · PVG 09:15 · LAX 18:15 · JFK 21:15
    ♥ Do have faith in what you're doing.