1. 别名
s = '' name = ['张三', '李四', '王五'] for i in range(len(name)): s += "'" + name[i] + "'" + ' as ' + 'x' + str(i+1) + ', ' print(s[:-2]) ''' '张三' as x1, '李四' as x2, '王五' as x3 '''
"'{}' as x{}, ".format(name[i], str(i+1))
1. 别名
s = '' name = ['张三', '李四', '王五'] for i in range(len(name)): s += "'" + name[i] + "'" + ' as ' + 'x' + str(i+1) + ', ' print(s[:-2]) ''' '张三' as x1, '李四' as x2, '王五' as x3 '''
"'{}' as x{}, ".format(name[i], str(i+1))