python实现列表中各元素的拼接,python拼接,功能要求: 假
python实现列表中各元素的拼接,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]
结果如下:
python实现列表中各元素的拼接
相关内容
- Python—MySQL线程池,,python实现版本
- Python pandas DataFrame操作,,1. 从字典创建Da
- #MySQL for Python(MySQLdb) Note,,#MySQL for
- 分享《Python深度学习》高清中文版pdf+高清英文版pdf+源
- 使用python requests库写接口自动化测试--记录学习过程中
- Python重写C语言程序100例--Part7,python--part7,‘‘‘【程序
- python执行shell指令的几种方法,pythonshell,1.os.syste
- Python 代码优化基础——判断对象类型,,# -*- codi
- mysql与python3交互,,ubuntu端安装s
- PYTHON访问数据库,,PYTHON DB
评论关闭