Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a="Hello World"
>>> b=a.encode("utf-8")
>>> b
b'Hello World'
>>> b[0]
72
>>> b[:1]
b'H'
>>> a[0]
'H'
>>> a[:1]
'H'
>>> type(b[0])
<class 'int'>
>>> c = [i for i in range(10)]
>>> c
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> c[0]
0
>>> c[:1]
[0]
>>>

bytes的元素都是range(256)的元素,bytes的切片都是bytes类型。

str的元素都是str(python没有char的概念),str的切片还是str类型。

列表的元素是元素的类型,列表的切片还是列表。

*所以说str是特殊的列表,bytes是特殊的str?

最新文章

  1. Struts2中的EasyUI
  2. 用php脚本给html中引用的js和css路径打上版本
  3. hdu3038(带权并查集)
  4. No.5__C#
  5. This function has none of DETERMINISTIC, NO SQL 解决办法
  6. E1114 Temp Ambient
  7. Axure RP
  8. pylinter could not automatically determined the path to `lint.py`
  9. trie树信息抽取之中文数字抽取
  10. Activity启动过程分析
  11. C++ STL map详解
  12. poj 2230详解
  13. APIO2010特别行动队
  14. Python中将一个对象倒序输出的4种方法
  15. UVA 11488 Hyper Prefix Sets (字典树)
  16. 对前台传过来的实体是否为空 进行为空校验的N种方法
  17. ORACLE生成唯一标识函数
  18. 自己从0开始学习Unity的笔记 IV (C#循环练习输出素数)
  19. python笔记03-----文件操作
  20. Python partition() 方法

热门文章

  1. Excel获取当前日期和时间
  2. 【Python系统学习03】错误类型整理(一)
  3. Go Web 编程之 模板(一)
  4. vue报错 [Intervention] Ignored attempt to cancel a touchmove event with cancelable
  5. Scala实践9
  6. 清晰架构(Clean Architecture)的Go微服务: 依赖注入(Dependency Injection)
  7. Task 线程重用导致等待!
  8. python如何计算程序(代码块)的运行时间?
  9. 搭建自己的Online Judge
  10. SliverAppBar 介绍及使用