Nul*_*ptr 1 python list
我正在学习Python.我想做以下任务:
['a', 'b', 'c']
例如,我想添加"-temp"到列表中的每个元素.所以,输出将是:
"-temp"
"a-temp b-temp c-temp"
当然,我可以写C/C++风格.但是,Python中有更优雅或有趣的方式吗?
Dan*_* D. 8
>>> ' '.join( x+'-temp' for x in ['a', 'b', 'c'] ) 'a-temp b-temp c-temp'
归档时间:
14 年,8 月 前
查看次数:
118 次
最近记录: