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基于json文件实现的gearman任务自动重启代码实例

一:在gearman任务失败后,调用task_failed def task_failed(task, *args): info = '\n'.join(args) dat...

Python 实现异步调用函数的示例讲解

async_call.py #coding:utf-8 from threading import Thread def async_call(fn): def wrapper...

Python父目录、子目录的相互调用方法

Python父目录、子目录的相互调用方法

最近在使用Python的过程中经常遇到找不到该模块的问题。其中一个就是父目录子目录之间相互调用的情况。下面简单总结下。 我们在F:\Code文件夹下面创建一个test文件夹 而test...

python for 循环获取index索引的方法

使用 enumerate 函数 可以返回下标。 例如 for inx, val in enumerate(['uyy', 'dfdf']): print(inx) pri...

Python中利用sqrt()方法进行平方根计算的教程

 sqrt()方法返回x的平方根(x>0)。 语法 以下是sqrt()方法的语法: import math math.sqrt( x ) 注意:此函数是无法直...