V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
omg21
V2EX  ›  Python

用 base64 编码过的字符带 b',如何存入数据库?

  •  
  •   omg21 · 2016-07-09 21:44:01 +08:00 · 4038 次点击
    这是一个创建于 2862 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我在把带有单引号和双引号还有其他特殊字符的网页代码存入数据库时用了 base64 转换,但是转换后的字符串带了个 b'...',现在还是没法代换到 SQL 的 values('%s')里,应该怎么解决?
    5 条回复    2016-07-10 18:49:25 +08:00
    imn1
        1
    imn1  
       2016-07-09 22:07:10 +08:00
    decode
    billlee
        2
    billlee  
       2016-07-09 23:42:42 +08:00
    decode('ascii')
    notgod
        3
    notgod  
       2016-07-10 09:20:04 +08:00 via iPhone
    搜索 php mysql 转义
    非 php 也一样 都有转义函数

    自动加 /

    专门应对这种情况 你不看文档的吗?
    beginor
        4
    beginor  
       2016-07-10 11:49:37 +08:00 via Android
    插入式不能做参数化么?
    iyangyuan
        5
    iyangyuan  
       2016-07-10 18:49:25 +08:00 via iPhone
    这,是个 orm 框架都会做转义吧?不要自己拼 sql
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1572 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:07 · PVG 01:07 · LAX 10:07 · JFK 13:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.