| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 924 人关注过本帖
标题:不知道s=b'hello'什么意思,在这请教各位
只看楼主 加入收藏
tanjianyong
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-11-1
收藏
 问题点数:0 回复次数:1 
不知道s=b'hello'什么意思,在这请教各位
s=b'hello world'
谁能告诉我b' '的作用是什么,谢谢
搜索更多相关主题的帖子: hello world 
2011-12-16 11:00
wynemo
Rank: 2
等 级:论坛游民
帖 子:12
专家分:42
注 册:2010-7-17
收藏
得分:0 
http://
根据这里的回答python2.6之前没有 b''这种写法 2.6,2.7中这种写法和普通的''没区别

而在3.x中 b''的意思是 Bytes literals, 是python 3的新类型

根据这里的说法的话 http://www.

Motivation
    Python's current string objects are overloaded.  They serve to hold
    both sequences of characters and sequences of bytes.  This
    overloading of purpose leads to confusion and bugs.  In future
    versions of Python, string objects will be used for holding
    character data.  The bytes object will fulfil the role of a byte
    container.  Eventually the unicode type will be renamed to str
    and the old str type will be removed.

看上去想把2.x中的str的byte容器功能给这个bytes类型   而unicode类型将取代str类型  原有的str类型将被移除

也就是 比如说以前在2.x 写某些网络程序时 发送字节序 'exit\r\n'
现在在3.x中要这样写 b'exit\r\n'
2012-07-15 22:08
快速回复:不知道s=b'hello'什么意思,在这请教各位
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014180 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved