【发布时间】:2014-09-10 09:02:13
【问题描述】:
我需要一个“单行”Python 语句,它生成一个元组,其中只包含带有“@”的字符串。
Input:
tuple_1 = ('asdf@', 'asdf') #the given (not included in the 2 lines)
我的尝试:2 行
for string in tuple_1:
if '@' in string: tuple_2 = (string)
Out:
tuple_2 = ('asdf@')
【问题讨论】:
标签: python python-2.7 tuples