Python零基础学习代码实践 —— 模拟播放器中的歌词显示
import time musucLrc = ''' [00:00.01]给我你的爱 [00:02.01]林宥嘉,张杰 [00:05.53] 作词:秋风 [00:09.83] 作曲:秋风 [00:14.90] [00:15.65]相信我 在每个生命的路口 [00:20.98]在每个无助的时候 [00:24.75]都有对爱的渴求 [00:30.47]我想把 真的爱向你传达 [00:36.53]无论你在海角天涯 [00:39.52]都能感到 我的牵挂 [00:44.28]请给我你的爱 [00:47.84]请伸出手来传递这信赖 [00:51.54]就在这茫茫人海 [00:53.79]真心的爱 让世界变色彩 [00:59.02]请给我你的爱 [01:02.45]让我们用爱改变着未来 [01:06.10]在每个艰难时刻 [01:08.88]伸你的手 感觉真的爱 [01:14.81]牵着手 让我们静静地感受 [01:19.92]当风雨艰难过去后 [01:23.79]那种美好的自由 [01:29.29]我们都曾 错过幸福的意义 [01:34.77]只希望我还来得及 [01:38.45]去告诉你 真心爱你 [01:43.15]请给我你的爱 [01:47.39]请伸出手来传递这信赖 [01:50.42]就在这茫茫人海 [01:53.18]真心的爱 让世界变色彩 [01:57.72]请给我你的爱 [02:01.53]让我们用爱改变着未来 [02:05.19]在每个艰难时刻 [02:07.86]伸你的手 感觉真的爱 [02:14.27]我不再想要错过 [02:15.81]你的每个热切期待 [02:19.18]用爱 在明天到来之前 [02:22.56]向你大声说出爱~~爱 [02:29.44]请给我你的爱 [02:32.65]请伸出手来传递这信赖 [02:36.33]就在这茫茫人海 [02:39.08]真心的爱 让世界变色彩 [02:43.89]请给我你的爱 [02:47.56]让我们用爱改变着未来 [02:51.05]在每个艰难时刻 [02:53.96]伸你的手 感觉真的爱 [03:01.38]给我你的爱~~ ''' #将数据分解存储到字典里 lrcDict = {} musicList = musucLrc.splitlines() for lrcLine in musicList: #runCount = lrcLine.count(":") lrcLineList = lrcLine.split("]") for index in range(len(lrcLineList) - 1): timeStr = lrcLineList[index][1:] #print(timeStr) timeList = timeStr.split(":") timea = float(timeList[0]) * 60 + float(timeList[1]) #print(timea) lrcDict[timea] = lrcLineList[-1] #print(lrcDict) allTimeList = [] for t in lrcDict: allTimeList.append(t) allTimeList.sort() #print(allTimeList) #在字典里将数据调出来然后按照时间间隔将数据显示出来 #效果是一行一行的刷新 getTime = 0 while 1: for n in range(len(allTimeList)): tempTime = allTimeList[n] if getTime < tempTime: break lrc = lrcDict.get(allTimeList[n]) if lrc == None: pass else: print(lrc) if n in range(len(allTimeList) - 1): time.sleep(allTimeList[n + 1] - allTimeList[n]) getTime += (allTimeList[n + 1] - allTimeList[n]) else: break
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
SAP S/4HANA里如何创建Customer主数据以及执行后续处理
来自Jerry的同事Zhang Sean. 1, Launch tcode: BP and select the Organization2, Maintain the information for Customer role3, Maintain information for name and search4, Maintain the Address5, Maintain the information for Sales and Distribution 6, then maintain which Sales Area this customer is assigned to, you could also maintain the information for other Sales Area by the butto
- 下一篇
Python零基础学习笔记(二十二)—— set
''' set:类似dict,是一组key的集合,不存储value 本质:无序和无重复元素的集合 用途:经常用于去除list和tuple中的重复元素 ''' #创建 #创建set 需要一个list或者tuple或者dict作为输入集合 #重复元素在set中会自动被过滤 set1 = set([1, 2, 2, 2, 3, 4, 5]) print(set1) set2 = set((1, 2, 3, 1, 2, 3)) print(set2) set3 = set({1:"2" , 3: "4", 5: "2"}) print(set3) #添加 注意;列表不能作为key,而set里面存的就是key,所以不能添加list[] set1.add(5) print(set1) set2.add((1,2,1,5)) print(set2) #set3.add({1,2}) #会报错 #插入整个list tuple 字符串,打碎插入 set1.update([12,3]) print(set1) set1.update((22,23,24,24)) print(set1) set1.upda...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- CentOS7安装Docker,走上虚拟化容器引擎之路
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- SpringBoot2全家桶,快速入门学习开发网站教程
- CentOS8编译安装MySQL8.0.19
- Jdk安装(Linux,MacOS,Windows),包含三大操作系统的最全安装