Python从MP3文件获取id3的方法

yipeiwu_com6年前Python基础

本文实例讲述了Python从MP3文件获取id3的方法。分享给大家供大家参考。具体如下:

def getID3(filename):
  fp = open(filename, 'r')
  fp.seek(-128, 2)
  fp.read(3) # TAG iniziale
  title  = fp.read(30)
  artist = fp.read(30)
  album  = fp.read(30)
  anno  = fp.read(4)
  comment = fp.read(28)
  fp.close()
  return {'title':title, 'artist':artist, 'album':album, 'anno':anno}

希望本文所述对大家的Python程序设计有所帮助。

相关文章

Python模拟百度自动输入搜索功能的实例

如下所示: # 访问百度,模拟自动输入搜索 # 代码中引入selenium版本为:3.4.3 # 通过Chrom浏览器访问发起请求 # Chrom版本:59 ,chromdrive...

python导入csv文件出现SyntaxError问题分析

背景 np.loadtxt()用于从文本加载数据。 文本文件中的每一行必须含有相同的数据。 *** loadtxt(fname,dtype=<class'float'>,co...

python 排列组合之itertools

python 2.6 引入了itertools模块,使得排列组合的实现非常简单:复制代码 代码如下:import itertools  有序排列:e.g., 4个数内选2个排列...

Python中应该使用%还是format来格式化字符串

%还是format 1、皇城PK Python中格式化字符串目前有两种阵营:%和format,我们应该选择哪种呢? 自从Python2.6引入了format这个格式化字符串的方法之后,我...

如何将python中的List转化成dictionary

如何将python中的List转化成dictionary

问题1:如何将一个list转化成一个dictionary? 问题描述:比如在python中我有一个如下的list,其中奇数位置对应字典的key,偶数位置为相应的value 解决方案:...