'xxxxx'
>>>
str(tuple(s))
"('x', 'x', 'x', 'x', 'x')"
参考链接:
http://blog.csdn.net/sruru/article/details/7803208
http://stackoverflow.com/questions/5618878/how-to-convert-list-to-string
http://piziyin.blog.51cto.com/2391349/568426
http://stackoverflow.com/questions/33054527/python-3-5-typeerror-a-bytes-like-object-is-required-not-str
list()方法是把字符串str或元组转成数组tuple()方法是把字符串str或数组转成元组>>> s = "xxxxx">>> list(s)['x', 'x', 'x', 'x', 'x']>>> tuple(s)('x', 'x', 'x', 'x', 'x')>>> tuple(list(s))('x', 'x', 'x', 'x', 'x')>>> list(tuple
1. 概述
Python
中的序列类:列表 (
list
),
元组
(
tuple
),字符串(
str
)最主要的共性:支持下标访问序列元素,例如
list
[1],
tuple
[0],
str
[1]。每个类都是使用数组这种低层次的概念来表示序列。
2. 数组
2.1 存储机制
计算机是以字节(1 字节 = 8 位)为单位存储和访问数据的,并且存储器的任一单元被存储或检索的运行时间为 O(1)。
数组:一组相关变量能够一个接一个地存储在计算机存储器的一块连续的区域内。
数组的每个单元必须占据相同数量的字节!Why:这样可以云讯使用索引值在常量时间内访问数组的任一单元!
地址 = 起始地址 + 索引 * 单元
在
Python
2中map函数会返回一个
list
列表,但在
Python3
中,返回<map object at 0x********>
map()会根据提供的函数对指定序列做映射。
第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。
map() 函数语法:
map(function, iterable, ...)
print(map(
str
, [1, 2, 3, 4]))
lis...
(123, 'abc', ['come', 'here'])
上面例子中看到的变量t,并没有报错,也没有“最后一个有效”,而是将对象做为一个新的数据类型:
tuple
(
元组
),赋值给了变量t。
元组
是用圆括号括起来的,其中的元素
之间
用逗号隔开。(都是英文半角)
tuple
是一种序列类型的数据,这点上跟
list
/
str
类似。它的特点就是
eval是
Python
的一个内置函数,这个函数的作用是,返回传入字符串的表达式的结果。想象一下变量赋值时,将等号右边的表达式写成字符串的格式,将这个字符串作为eval的参数,eval的返回值就是这个表达式的结果。
eval函数就是实现
list
、dict、
tuple
与
str
之间
的
转
化,
str
函数把
list
,dict,
tuple
转
为为字符串
一、字符串
转换
成列表
a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]"
print(type(a))
b = eval(a)
eval函数就是实现
list
、dict、
tuple
与
str
之间
的
转
化
str
函数把
list
,dict,
tuple
转
为为字符串
一、字符串
转换
成列表
a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]"
print(type(a))
b = eval(a)print(type(b))
print(b)
二、字符串
转换
成字典
a = ...
resolution will not be reattempted until the update interval of XXX has elapsed or updates are force
117054