我有一个这样的清单。
['February 01,2011 - February 28, 2011', 'March 01,2011 - March 31, 2011']
我想将其转换为
[('February 01,2011 - February 28, 2011'), ('March 01,2011 - March 31, 2011')]
任何想法? 请帮忙!!! 在此先感谢!!!
答案 0 :(得分:12)
要制作包含1个元素的元组,请在括号中添加逗号:
>>> my_list = ['February 01,2011 - February 28, 2011', 'March 01,2011 - March 31, 2011']
>>> [(x,) for x in my_list]
[('February 01,2011 - February 28, 2011',), ('March 01,2011 - March 31, 2011',)]