When I print a program such as this in Python:

x = b'francis'

The output is b'francis'. If bytes is in 0's and 1's why is it not printing it out?

解决方案

You seem to be fundamentally confused, in a very common way. The data itself is a distinct concept from its representation, i.e. what you see when you attempt to print it out or otherwise display it. There may be multiple ways to represent the same data. This is just like how if I write 23 (in decimal) or 0x17 (hexadecimal) or 0o27 (octal) or 0b10111 (binary) or twenty-three (English), I am talking about the same number.

At some lower level below Python, everything is bytes, and each byte consists of bits; but it is not correct to say that the bytes "are in" 0s and 1s - just like how it is not correct to say that the number twenty-three "is in" decimal digits (or hexadecimal, octal or binary ones, or in English text characters).

The symbols 0 and 1 are just pictures that we draw on a screen to represent the state of those bits - if we choose to represent them individually. Sometimes, we choose larger groupings, and assign different symbols to various combinations of states. For example, we may interpret multiple bits as a single integer value in binary; or (using Unicode) we might further interpret that number as a "code point" (most of these are text characters; some are control characters, or portions of text characters).

A Python bytes object is a wrapper for a "raw" sequence of bytes. When you display it, Python uses a representation where each byte (grouping of 8 bits) corresponds to one or more symbols: bytes whose corresponding integer value is between thirty-two and one hundred twenty-six (inclusive) are (for historical reasons) represented using individual text characters (following the so-called ASCII encoding), while others are represented with a four-character "escape sequence" beginning with \x and followed by the hexadecimal representation of the number.

python打印二进制内容,Python字节不打印二进制相关推荐

  1. python必背内容-python必背函数

    广告关闭 2017年12月,云+社区对外发布,从最开始的技术博客到现在拥有多个社区产品.未来,我们一起乘风破浪,创造无限可能. 今天给大家分享一些学习python必须认识的英文单词,同时也是学习编程都 ...

  2. 浏览器调用打印功能打印页面内容(可全局打印,可局部打印)

    function printhtml() {var ht = $('#xxx').html(); //局部打印,全局打印的话直接调用windows.document.print()即可var h = ...

  3. 【Word技巧】打印部分内容或者隐藏不打印的内容,如何操作?

    在工作中,我们经常需要打印各种Word文档,但有时候,我们只需要打印文档的其中一部分内容,或者有部分内容并不想打印出来,要如何操作呢? 还不了解的小伙伴,可以看看下面的方法哦. 一.设置打印其中一部分 ...

  4. 怎么在python下载网站内容-python从网站上下载东西

    import requests res=requests.get('http://www.gutenberg.org/cache/epub/112/pg112.txt')#requests返回一个re ...

  5. 怎么在python下载网站内容-Python下载网页的几种方法

    get和post方式总结 get方式:以URL字串本身传递数据参数,在服务器端可以从'QUERY_STRING'这个变量中直接读取,效率较高,但缺乏安全性,也无法来处理复杂的数据(只能是字符串,比如在 ...

  6. python读取文件内容-Python读取文件内容与存储

    Python读取与存储文件内容 一..csv文件 读取: importpandas as pd souce_data= pd.read_csv(File_Path) 其中File_path是文件的路径 ...

  7. python项目简历内容-python编程工程师简历模板范文

    个人信息 姓名:XXX 最高学历: 硕士 年龄:27 性别:男 婚姻状况:已婚 求职意向:python开发工程师 手机:12312345678 邮箱:lingxian@capablist.com 教育 ...

  8. html中打印部分内容,设置网页打印区域

    这里设置多段打印区域 html中代码如下: <!--startprint1--> <div class="theme"><p><span ...

  9. python打印小票_PyQt5中使用Qprinter打印热敏小票

    在<PyQt5中使用QWebChannel和内嵌网页进行js交互>一文中,我记录了如何使用QWebchannel与内嵌网页进行js交互,其根本目标在于使用Qt5调起打印机服务.在这篇文章中 ...

最新文章

  1. 她是直播聊学习成“网红”的北大博士,毕业后入职民办学校,年薪70万
  2. MVC中实现多按钮提交(转)
  3. webclient 请求期间发生异常_ARM异常中断的原因及处理措施
  4. 解决windows7您当前无权访问该文件夹的问题
  5. PHP错误处理函数set_error_handler()的用法
  6. 浏览器打开出现证书错误_PADI 电子潜水证书更新啦!
  7. 网络编程的4种IO模型
  8. eclipse合并svn分支方法
  9. SpringBoot--定义全局日期响应格式
  10. OPENCV C++ 找到最大内接矩形(正方形)
  11. 计算机进制转换练习,二进制十进制八进制十六进制转换练习题.docx
  12. 百度旋转验证码识别平台接口文档
  13. CPU怎么选择,单核cpu与多核cpu的区别
  14. Redis数据库(二)
  15. Andriod Studio 线性布局(LinearLayout)
  16. python第三方库re库基本介绍
  17. 物联网跟人的神经网络相似通过各种信息传感设备
  18. 【深度学习基础知识 - 25】提升模型泛化能力的方法
  19. Android LifeCycle详解
  20. php-调用阿里云第三方短信接口

热门文章

  1. 现代谱估计:多窗口谱相关性
  2. mqtt android封装,Android之MQTT封装使用
  3. VS2013运行报错error C4996: 'scanf': This function or variable may be unsafe.
  4. 【算法】一个简单的k均值(k-means)原理
  5. 【算法】一个简单的主成分分析(PCA)原理
  6. 云炬随笔20171203
  7. 台湾大学林轩田机器学习基石课程学习笔记1 -- The Learning Problem
  8. java获取2017年第39周_java中怎么样取出39周的每周开始时间和每周结束时间?
  9. python嵌套字典代码_python – 尝试在嵌套字典中查找唯一值的总和. (见例子!)
  10. [scala-spark]3. 变量 数据类型 分支与循环