003_004 Python 获取列表中所有歌曲播放时间总和
2014-03-23 14:15
447 查看
代码如下:
打印结果如下:
中国
0:06:11
#encoding=utf-8 print '中国' #获取列表中所有歌曲播放时间总和 import datetime #sum的第二个参数主要用于指出类型 def totaltime(times): td = datetime.timedelta(0) duration = sum([datetime.timedelta(minutes=m,seconds=s) for m,s in times],td) return duration times1=[(2,36),(3,35)] print totaltime(times1)
打印结果如下:
中国
0:06:11
相关文章推荐
- 解决python中matplotlib绘图中文显示问题
- Python中range和xrange的用法
- Python中map()函数浅析
- Python中matplotlib绘图介绍
- python 网站自动抠图
- python模板引擎Cheetah的安装
- python程序设计基础2:python数据类型
- Python 连接mysql数据库
- 使用easy_install,ipython报错
- python socket
- 10. python
- Python中dict字典使用方法
- python实现堆栈和队列
- wxPython的Refresh与事件双重响应
- Python学习资源收集
- python入门教程、基本类型的操作及相互转换
- python爬虫框架
- SL4A、QPython学习笔记(2)
- 基于saltstack实现的配置集中化管理
- MySQL for Python(一)