1. 别名

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

  "'{}' as x{},\n".format(name[i], str(i+1))

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2023-03-07
  • 2021-06-28
  • 2021-08-17
  • 2021-12-27
  • 2022-03-07
  • 2022-02-23
猜你喜欢
  • 2021-11-06
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-05-03
  • 2022-12-23
相关资源
相似解决方案