Lists and strings
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
Lists and strings的更多相关文章
- Think Python - Chapter 10 - Lists
		10.1 A list is a sequenceLike a string, a list is a sequence of values. In a string, the values are ... 
- 如何将List<string>转化为string
		Convert List, string. A List can be converted to a string. This is possible with the ToArray method ... 
- 自然语言16.1_Python自然语言处理学习笔记之信息提取步骤&分块(chunking)
		QQ:231469242 欢迎喜欢nltk朋友交流 http://www.cnblogs.com/undercurrent/p/4754944.html 一.信息提取模型 信息提取的步骤共分为五步,原 ... 
- Python  系列:1 - Tuples and Sequences
		5.3 Tuples and Sequences We saw that lists and strings have many common properties, e.g., indexing a ... 
- Device Tree Usage( DTS文件语法)
		http://elinux.org/Device_Tree_Usage Device Tree Usage Top Device Tree page This page walks throu ... 
- Python数据结构与算法--数据类型
		从数据类型开始 Python支持面向对象的编程范式,这意味着Python把数据看成解决问题的关键. 在Python中,类似其他的面向对象的编程语言, 我们定义一个类,用来描述数据是什么 (状态) 和数 ... 
- python中的yield
		在理解yield之前,要首先明白什么是generator,在理解generator之前首先要理解可迭代的概念. 可迭代(iterables)在你创建一个list的时候,可以逐个读取其中的元素,该逐个读 ... 
- Think Python - Chapter 18 - Inheritance
		In this chapter I present classes to represent playing cards, decks of cards, and poker hands.If you ... 
- Class attributes
		In order to print Card objects in a way that people can easily read, we need a mapping from the inte ... 
随机推荐
- 玩转Android Camera开发(三):国内首发---使用GLSurfaceView预览Camera 基础拍照demo
			GLSurfaceView是OpenGL中的一个类,也是能够预览Camera的,并且在预览Camera上有其独到之处. 独到之处在哪?当使用Surfaceview无能为力.痛不欲生时就仅仅有使用GLS ... 
- 显示解析svg
			g公司代码显示svg: SVGParserRenderer drawable = new SVGParserRenderer(context, String svgContent); String s ... 
- 2.QT字符串及一些基本操作
			mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { c ... 
- 递归进制转换_strrev
			#define _CRT_SECURE_NO_WARNINGS #include <stdlib.h> #include <stdio.h> #include <stri ... 
- Windows常见软件故障及解决方案
			HM NIS Edit: HM NIS Edit 新建程序向导无效,提示“Please specify the setup lang” 说明 NSIS 安装不对.解决方案有二种: 1. 重装 NSIS ... 
- POJ 1064 Cable master (二分答案,G++不过,C++就过了)
			题目: 这题有点坑,G++过不了,C++能过. 条件:n个数据a[],分成k段,结果精度要求两位小数. 问题:每段最长为多少? 思路:因为精度要求为两位小数,我先把所有的长度a[]*100. 我们对答 ... 
- Codeforces 845A. Chess Tourney  思路:简单逻辑题
			题目: 题意:输入一个整数n,接着输入2*n个数字,代表2*n个选手的实力. 实力值大的选手可以赢实力值小的选手,实力值相同则都有可能赢. 叫你把这2*n个选手分成2个有n个选手的队伍. ... 
- SLAM概念学习之随机SLAM算法
			这一节,在熟悉了Featue maps相关概念之后,我们将开始学习基于EKF的特征图SLAM算法. 1. 机器人,图和增强的状态向量 随机SLAM算法一般存储机器人位姿和图中的地标在单个状态向量中,然 ... 
- POJ 1182 食物链 【并查集】
			解题思路:首先是没有思路的----然后看了几篇解题报告 http://blog.csdn.net/ditian1027/article/details/20804911 http://poj.org/ ... 
- 3ds Max制作碗实例教程
			一. 碗的建模.模型的结果如图WB—1所示: 图WB—1 1. 创建圆柱,并调节参数,转换到多边形,最终的结果图WB—2所示: 图WB—2 2.使用Inset(插入)插入一个面,再次执行Extrude ... 
