大数据实验室作业总结

本文总结了大数据实验室的作业,包括使用Python进行网络爬虫,爬取音乐资源;利用matplotlib库绘制三维图形;通过turtle库实现七段数码管显示;以及使用C语言创建链表。这些实践不仅涵盖了数据抓取、数据可视化、图形界面编程和数据结构等多个方面,还展示了Python和C语言在实际项目中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

大数据实验室作业总结

import re
import requests
import json

url = ‘http://music.taihe.com/search
singer = {
“key”:“周杰伦”
}
response = requests.get(url,params=singer)
html = response.text
#print(html)
#print(reponse)
sids = re.findall(r’data-playdata="(.+?)"’,html)
#print(sids)
id_list = re.findall(r’\d+’,sids[0])
#print(id_list)

for i in id_list:
api = “http://musicapi.taihe.com/v1/restserver/ting?method=baidu.ting.song.playAAC&format=jsonp&callback=jQuery17202628249451505169_1542286502046&songid=%s&from=web&_=1542286504081”%i
#print(api)
response = requests.get(api)
data =response.text
#print(data)
data1=re.findall(r"((.*))",data)[0]
#print(data1)
data2=json.loads(data1)
mp3_name=data2[‘songinfo’][‘title’]
mp3_url = data2[‘bitrate’][‘file_link’]
print(mp3_name,mp3_url)
mp3 = requests.get(mp3_url)
with open (“E:\zhoujielun %s mp3”% mp3_name,‘wb’) as f:
f.write(mp3.content)
这个是百度音乐爬虫的代码,这个其实实用性很大,可以爬取很多自己想要的资料
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np

fig = plt.figure()
ax = fig.gca(projection=‘3d’)
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X2 + Y2)
Z = np.sin®

surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
linewidth=0, antialiased=False)

ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter(’%.02f’))

fig.colorbar(surf, shrink=0.5, aspect=5)

plt.show()

这个是用matplotlib.库做一个三维的图形,虽然自己做的的不是很好,但是也从代码中学到了很多东西
import turtle
def drawGap(): #绘制数码管间隔
turtle.penup()
turtle.fd(5)
def drawLine(draw): #绘制单段数码管
drawGap()
turtle.pendown() if draw else turtle.penup()
turtle.fd(60)
drawGap()
turtle.right(90)
def drawDigit(x): #根据数字绘制七段数码管
drawLine(True) if x in [2,3,4,5,6,8,9] else drawLine(False)
drawLine(True) if x in [0,1,3,4,5,6,7,8,9] else drawLine(False)
drawLine(True) if x in [0,2,3,5,6,8,9] else drawLine(False)
drawLine(True) if x in [0,2,6,8] else drawLine(False)
turtle.left(90)
drawLine(True) if x in [0,4,5,6,8,9] else drawLine(False)
drawLine(True) if x in [0,2,3,5,6,7,8,9] else drawLine(False)
drawLine(True) if x in [0,1,2,3,4,7,8,9] else drawLine(False)
turtle.left(180)
turtle.penup()
turtle.fd(30)
#运行主程序
turtle.setup(900, 500)#展开画板
turtle.penup()
turtle.fd(-350)
turtle.pensize(5)
a=open(r"C:\Users\24218\520.txt")#引用文件
b=a.readlines()
b=b[0].split()
for i in range(0,len(b)):
b[i]=int(b[i])
a.close()
for x in b : #画出5201314
drawDigit(x)
turtle.hideturtle()
turtle.done()
这个是七段数码管的代码
在这里插入代码片#include <stdio.h>
#include <malloc.h>
#define LEN sizeof(struct wyc)
struct wyc
{
long num;
float score;
struct wyc*next;
};
int n;
struct wyc * creat()
{
struct wyc *head,*p1,*p2;
n=0;
p1=p2=( struct wyc *)malloc(LEN);
scanf("%ld%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct wyc *)malloc(LEN);
scanf("%ld%f",&p1->num,&p1->score);
}
p2->next=NULL;
return head;
}
void print(struct wyc * head)
{
struct wyc *p;
printf("\nNow,These %d records are :\n",n);
p=head;
if(head!=NULL)
while(p!=NULL)
{printf("%ld %5.lf\n",p->num,p->score);
p=p->next;
}
}
int main()
{struct wyc *head;
head=creat();
print(head);
return 0;
}
`这个是建立链表的代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值