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的更多相关文章

  1. [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 ...

  2. 【python】python新手必碰到的问题---encode与decode,中文乱码[转]

    转自:http://blog.csdn.net/a921800467b/article/details/8579510 为什么会报错“UnicodeEncodeError:'ascii' codec ...

  3. LeetCode Encode and Decode Strings

    原题链接在这里:https://leetcode.com/problems/encode-and-decode-strings/ 题目: Design an algorithm to encode a ...

  4. Encode and Decode Strings

    Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...

  5. encode和decode

    Python字符串的encode与decode研究心得乱码问题解决方法 为什么会报错“UnicodeEncodeError: 'ascii' codec can't encode characters ...

  6. 【python】浅谈encode和decode

    对于encode和decode,笔者也是根据自己的理解,有不对的地方还请多多指点. 编码的理解: 1.编码:utf-8,utf-16,gbk,gb2312,gb18030等,编码为了便于理解,可以把它 ...

  7. 271. Encode and Decode Strings

    题目: Design an algorithm to encode a list of strings to a string. The encoded string is then sent ove ...

  8. [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 ...

  9. Encode and Decode Strings 解答

    Question Design an algorithm to encode a list of strings to a string. The encoded string is then sen ...

  10. python encode和decode函数说明【转载】

    python encode和decode函数说明 字符串编码常用类型:utf-8,gb2312,cp936,gbk等. python中,我们使用decode()和encode()来进行解码和编码 在p ...

随机推荐

  1. [转]JAVA Iterator 的用法

    java.util包中包含了一系列重要的集合类.本文将从分析源码入手,深入研究一个集合类的内部结构,以及遍历集合的迭代模式的源码实现内幕. 下面我们先简单讨论一个根接口Collection,然后分析一 ...

  2. c#-day02学习笔记

    类型转化 为什么要类型转化:因为C#语言是强类型的语言,所以区分了很多的类型,类型和类型之间是不能直接赋值的,如果要赋值 就需要转换类型 类型转换分为两大类: 第一类:隐式转换 隐式转换是系统默认的转 ...

  3. Excel数据导入数据库

    maven依赖 <!--excel相关依赖--> <dependency> <groupId>org.apache.poi</groupId> < ...

  4. 浏览器缓存介绍之sessionStorage、localStorage、Cookie

    Cookie Cookie 是小甜饼的意思.顾名思义,cookie 确实非常小,它的大小限制为4KB左右,是网景公司的前雇员 Lou Montulli 在1993年3月的发明.它的主要用途有保存登录信 ...

  5. HTML知识点梳理

  6. JavaScript 原型链 OOP(二)

    原型对象 `prototype` -  原型对象的所有属性和方法,都能被实例对象共享;   JavaScript 通过构造函数生成新对象,因此构造函数可以视为对象的模板.实例对象的属性和方法,可以定义 ...

  7. Vue.js - Day1

    什么是Vue.js Vue.js 是目前最火的一个前端框架,React是最流行的一个前端框架(React除了开发网站,还可以开发手机App, Vue语法也是可以用于进行手机App开发的,需要借助于We ...

  8. 将pugixml库编译成动态库的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 pugixml库默认是编译成静态库的.要把pugixml库编译成一个动态库,需要对代码做一些修改,具体是将 // If ...

  9. Linux 学习 三, linux 文件结构

    linux 的文件结构 linux 下的bin 目录,包含了常用的命令应用程序 /bin: bin为binary的简写主要放置一些系统的必备执行档例如:cat.cp.dmesg.gzip.kill.l ...

  10. APP常用检测

    检测设备.微信平台和app是否安装 // 检测是否安装了APP var isappinstalled = (function () { ); }()), // 检测ios设备 isIOS = (fun ...