标签:names pytho name col style mes div python 功能
功能要求:
假定有下面这样的列表:
names = [‘pear‘, ‘peach‘, ‘banana‘, ‘apple‘]
输出结果为:‘I have pear, peach, banana and apple.‘
源代码如下:
names = [‘fentiao‘, ‘fendai‘, ‘fensi‘, ‘apple‘]
print ‘I have ‘ + ‘,‘.join(names[:-1]) + ‘ and ‘ + names[-1]
结果如下:
标签:names pytho name col style mes div python 功能
原文地址:https://www.cnblogs.com/ChairmanYSL/p/9643748.html