is和==,encode和decode
0.编码解码
- >encode和decode
- a = "你好"
- s = a.encode("GBK")
- print(s)
- # b'\xc4\xe3\xba\xc3' 每一个\x是一个字节,每一个GBK占16bit,2个bytes,那么两个中文就是4个bytes,验证成功
- s1 = a.encode("UTf-8")
- print(s1)
- # b'\xe4\xbd\xa0\xe5\xa5\xbd' 每一个\x是一个字节,每一个UTF-8中文占24bit,3个bytes,那么两个中文就是6个bytes,验证成功
- b = "hello"
- b1 = b.encode("utf-8")
- print(b1)
- # b'hello' 在编解码英文时,不会换成16进制,会直接传输
- b2 = b.encode("gbk")
- print(b2)
- # b'hello'
- c = b'\xe4\xbd\xa0\xe5\xa5\xbd' # 解码,
- c1 = c.decode("utf-8")
- print(c1)
- # 你好
1.is和==的区别
- is和==
- # == 双等表⽰示的是判断是否相等, 注意. 这个双等比较的是具体的值.⽽而不是内存地址
- # is 比较的是数据存储在内存中的地址
- id
- aaa = "hello,world"
- bbb = "hello,world"
- print(id(aaa))
- #
- print(id(bbb)
- # 31339568 #返回的是同一个id,证明在内存中两个变量指向了同一个数据,这个就是针对字符串特有的小数据池
- lst = [1, 2, 4]
- print(id(lst))
- #
- lst1 = [1, 2, 4]
- print(id(lst1))
- #
- # 虽然两个列表的值是一样的,但是列表是不一样的, 两个列表中的值都是相同的指向
is和==,encode和decode的更多相关文章
- [LeetCode] Encode and Decode Strings 加码解码字符串
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...
- 【python】python新手必碰到的问题---encode与decode,中文乱码[转]
转自:http://blog.csdn.net/a921800467b/article/details/8579510 为什么会报错“UnicodeEncodeError:'ascii' codec ...
- LeetCode Encode and Decode Strings
原题链接在这里:https://leetcode.com/problems/encode-and-decode-strings/ 题目: Design an algorithm to encode a ...
- Encode and Decode Strings
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...
- encode和decode
Python字符串的encode与decode研究心得乱码问题解决方法 为什么会报错“UnicodeEncodeError: 'ascii' codec can't encode characters ...
- 【python】浅谈encode和decode
对于encode和decode,笔者也是根据自己的理解,有不对的地方还请多多指点. 编码的理解: 1.编码:utf-8,utf-16,gbk,gb2312,gb18030等,编码为了便于理解,可以把它 ...
- 271. Encode and Decode Strings
题目: Design an algorithm to encode a list of strings to a string. The encoded string is then sent ove ...
- [LeetCode#271] Encode and Decode Strings
Problem: Design an algorithm to encode a list of strings to a string. The encoded string is then sen ...
- Encode and Decode Strings 解答
Question Design an algorithm to encode a list of strings to a string. The encoded string is then sen ...
- python encode和decode函数说明【转载】
python encode和decode函数说明 字符串编码常用类型:utf-8,gb2312,cp936,gbk等. python中,我们使用decode()和encode()来进行解码和编码 在p ...
随机推荐
- Unity Shader 学习笔记(一)
_MainTex_ST (1)简单来说,TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)主要作用是拿顶点的uv去和材质球的t ...
- Devexpress Xtrareports 创建多栏报表
根据官方回答:多列或多行(取决于当前的多栏设置)呈现数据的报表 这种报表是有用的,例如,当每个明细区都只显示少量数据.并且需要在一列的右侧打印下一个明细区时,这样就能充分利用整个页面的宽度,此外,当创 ...
- 使用dtd--属性声明
<!ATTLIST 元素名 属性名称 属性类型 属性特点> 1.属性类型 类型 含义 CDATA 纯文本 enumerated 枚举类型 ID 以属性的方式唯一标识改元素,必须以字母开头 ...
- JQuery基础知识==jQuery选择器
选择器是jQuery的基础,在jQuery中,对事件处理.遍历DOM和Ajax操作都依赖于选择器 1. CSS选择器 1.1 CSS是一项出色的技术,它使得网页的结构和表现样式完全分离.利用CSS选择 ...
- Angular搭建脚手架
1.安装CLI: cnpm install -g @angular/cli //卸载: npm uninstall -g @angular/cli npm cache clean 2.检测是否成功 ...
- 零基础逆向工程39_Win32_13_进程创建_句柄表_挂起方式创建进程
1 进程的创建过程 打开系统 --> 双击要运行的程序 --> EXE开始执行 步骤一: 当系统启动后,创建一个进程:Explorer.exe(也就是桌面进程) 步骤二: 当用户双击某一个 ...
- Android基础Activity篇——Intent返回数据给上一个活动
1.如果活动B要将数据返回给活动A,那么需要以下三步: 1.1在活动A中使用startActivityForResult()方法启动活动B. 1.2在活动B中使用setResult()方法传回Iten ...
- formvalidator插件
一.引用jquery 二.引用formValidator.js //================================================================== ...
- QtWebkits如何向QtWebEngine过渡
QtWebkits如何向QtWebEngine过渡 1. 前言 很遗憾,QtWebkits在Qt5.6以上版本被淘汰了,对于这个接口良且和其他类例如QWebFrame完美结合的组件就这么没了,我只能表 ...
- Anaconda上安装Tensorflow并在jupyter上运行
博客原文地址:https://blog.csdn.net/index20001/article/details/73555182 https://www.cnblogs.com/HongjianChe ...