python 3 list、tuple(メタグループ)、str間の相互変換

2328 ワード

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(s))
['x', 'x', 'x', 'x', 'x']
                join  
>>> "".join(tuple(s))
'xxxxx'
>>> "".join(list(s))
'xxxxx'
>>> str(tuple(s))
"('x', 'x', 'x', 'x', 'x')"#    sublime text 3  sublimeREPl,            。    。
>>> 

参照リンク:
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