A string is a sequence of characters and a list is a sequence of values, but a list of characters is not the same as a string. To convert from a string to a list of characters, you can use the list function:

list breaks a string into individual letters. If you want to break a string into words, you can use split method:

An optional argument called a delimiter specifies which characters to use as word boundaries. The following example uses ‘, ‘ ( a comma followed by a space) as the delimiter:

join is the inverse of split.  It takes a list of strings and concatenates the elements. join is a string method, so you have to invoke it on the delimiter and pass the list as a parameter:

In this case, delimiter is a space character, so join puts a space between words. to concatenate strings without spaces, you can use the empty string, ‘’ as delimiter.

from Thinking in Python

最新文章

  1. nandflash驱动程序编写
  2. [zz] be similar with和be similar to的区别
  3. OpenCV学习笔记——多种Smooth平滑处理
  4. ios开发 json数据文件的存取
  5. get和post,session和cookie的一些说明
  6. SQVI和SAP查询QUERY的区别和使用注意事项
  7. match in shell scripts
  8. 设计社区Dribbble VS. Bēhance,你选谁?
  9. 团队作业6--展示博客(Alpha版本)
  10. SQL Server Service Broker创建单个数据库会话(消息队列)
  11. Java开发笔记(二十二)神奇的冒号
  12. DDoS的类型及原理
  13. Python 编程核心知识体系(REF)
  14. zepto 选中select option 的值
  15. C# MD5 加密,解密
  16. 高性能网络编程7--tcp连接的内存使用
  17. ASP.NET WebAPI Bearer Authorization
  18. mac rsync文件传输
  19. c语言for循环等语句详解
  20. ZOJ 3777 - Problem Arrangement - [状压DP][第11届浙江省赛B题]

热门文章

  1. 大话设计模式C++实现-第17章-适配器模式
  2. 禁掉Apache web server签名 How to turn off server signature on Apache web server
  3. 解题报告 之 HDU5317 RGCDQ
  4. iOS开发- 生成/解析.vcf文件
  5. js判断是对象还是集合
  6. ES API 备忘
  7. Ubuntu 18.04 关闭GUI
  8. Servlet简单计算器 2.0
  9. First-class citizen
  10. Vue export和import