国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - Python實現在線音樂播放器

Python實現在線音樂播放器

2020-09-22 09:36Donoy Python

這篇文章主要為大家詳細介紹了Python實現在線音樂播放器的相關資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

最近這幾天,學習了一下python,對于爬蟲比較感興趣,就做了一個簡單的爬蟲項目,使用Python的庫Tkinsert做了一個界面,感覺這個庫使用起來還是挺方便的,音樂的數據來自網易云音樂的一個接口,通過requests模塊,get請求將數據獲得,使用Json模塊進行數據的解析,最終使用python的mp3play庫進行對音樂的在線播放,以下是該程序的源碼。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2016-12-28 21:03:21
# @Author : Donoy (172829352@qq.com)
# @Link : http://www.cnblogs.com/Donoy/
# @Version : $Id$
 
from Tkinter import *
import tkMessageBox
import requests
import json
import urllib
import mp3play
import threading
import time
 
def center_window(root, width, height):
 screenwidth = root.winfo_screenwidth()
 screenheight = root.winfo_screenheight()
 size = '%dx%d+%d+%d' % (width, height, (screenwidth - width)/2, (screenheight - height)/2)
 root.geometry(size)
 
def createWnd():
 global root
 global listBox
 global text
 
 root = Tk()
 root.title('-----DMPlayer------來自網易云音樂-----')
 
 center_window(root, 440, 250)
 
 root['background'] = '#C7EDCC'
 
 text = Entry(font='宋體',width=36)
 text.pack()
 button = Button(root,text='搜索',width=18,fg='red',background='#CDCDC1',command=searchM).pack()
 
 listBox = Listbox(root, height=12,width=72,background='#C7EDCC')
 listBox.bind('<Double-Button-1>',play)
 listBox.pack()
 
 root.mainloop()
 
def searchM():
 global m_List
 itemCount = 50
 
 if not text.get():
 tkMessageBox.showinfo('溫馨提示','您可以輸入以下內容進行搜索\n1.歌曲名\n2.歌手名\n3.部分歌詞')
 return
 
 #獲得輸入的歌名
 url = 'http://s.music.163.com/search/get/?type=1&s=%s&limit=%s'%(text.get(),itemCount)
 
 #get請求
 header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'}
 html = requests.get(url,header)
 data = json.loads(html.text)
 m_List = []
 
 try:
 listBox.delete(0,listBox.size())
 for MusicData in data['result']['songs']:
  listBox.insert(END,MusicData['name'] +'------'+'(' +MusicData['artists'][0]['name'] + ')')
  m_List.append(MusicData['audio'])
 except Exception as e:
 tkMessageBox.showinfo('溫馨提示','查詢過程出現錯誤,請重試')
 #print '查詢過程出現錯誤,請重試'
 
 
def play(args):
 try:
 global mp3
 sy = listBox.curselection()[0]
 mp3 = mp3play.load(m_List[int(sy)])
 mp3.play()
 #time.sleep(1000)
 except Exception as e:
 pass
 
 
def main():
 createWnd()
 
 
if __name__ == '__main__':
 main()

程序運行結果:

Python實現在線音樂播放器

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 久久久www| 国产精品一区二区无线 | 日本免费在线 | 999国产在线观看 | 午夜精品一区 | 黄色小视频在线免费观看 | 这里只有精品在线 | 九九亚洲| 午夜视频在线观看网站 | 国产精品久久久久久婷婷天堂 | 青娱乐99| 国产乱码精品一区二区三区五月婷 | 三级黄色视频毛片 | 99久久国产露脸国语对白 | 五月婷婷激情 | 久久久久久久国产 | 欧美在线电影 | 成人精品动漫一区二区三区 | 久久精品| 99久久夜色精品国产亚洲1000部 | www.爱色av.com | 爱操在线| 久久亚洲精品中文字幕 | 伊人99综合 | 韩国精品一区二区 | 久久亚洲一区 | 亚洲一区中文字幕在线观看 | 欧美日韩精品一区二区三区 | 国产欧美综合一区二区三区 | 中文字幕免费观看 | 怡红院在线播放 | 黄色a视频 | 久久精品一区二区 | 亚洲成人aaaa | 日韩中文在线 | 国产视频久久 | 国产精品成人一区二区三区夜夜夜 | 黄色三级免费网站 | 亚洲午夜成激人情在线影院 | 亚洲精品乱码久久久久久金桔影视 | 成人久久久 |