1、遇到问题
有时候,会遇到这种错误:
description = description + '\n\n~~~' + log + '\n~~~'
TypeError: cannot concatenate 'str' and 'list' objects
怎么办呢?
自然是统一类型了,
所以就需要想办法互转类型。
2、list 转 string
>>> testlist = ['1', '2', '3']
>>> teststr = "".join(testlist)
>>> print teststr
123
>>> teststr = "\n".join(testlist)
>>> print teststr
1
2
3
>>> teststr = "-".join(testlist)
>>> print teststr
1-2-3
3、string 转 list
>>> teststr = "123"
>>> testlist = list(teststr)
>>> print testlist
['1', '2', '3']