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

"abc"转 b"abc",这样 string 直接转 byte, python 有没有方法?

  •  
  •   nicegoing · Oct 31, 2016 · 6029 views
    This topic created in 3621 days ago, the information mentioned may be changed or developed.
    我 google 下,都是 string 如何转 byte 的,请问如果简单的实现该功能。
    9 replies  •  2016-11-22 09:08:50 +08:00
    lll9p
        1
    lll9p  
       Oct 31, 2016 via Android
    eval 么 😂
    ethego
        2
    ethego  
       Oct 31, 2016
    bytearray()
    Mark3K
        3
    Mark3K  
       Oct 31, 2016
    In [2]: x.encode("utf-8")
    Out[2]: b'abc'
    soratadori
        4
    soratadori  
       Oct 31, 2016
    a = "abcdefg 你好"
    b = a.encode()
    print(b)
    Lonely
        5
    Lonely  
       Oct 31, 2016
    楼上都说了
    suixn
        6
    suixn  
       Oct 31, 2016
    encode
    nicegoing
        7
    nicegoing  
    OP
       Oct 31, 2016 via iPhone
    好吧.我傻了.被编码解码搞糊涂了
    GreatMartial
        8
    GreatMartial  
       Oct 31, 2016 via Android
    我也容易记反
    zungmou
        9
    zungmou  
       Nov 22, 2016 via iPhone
    @GreatMartial 总是容易把 encode 记做编码为某种字符编码的字符串。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2285 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 00:24 · PVG 08:24 · LAX 17:24 · JFK 20:24
    ♥ Do have faith in what you're doing.