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 ValueError: invalid literal for int() with base 10 实用解决方法

今天在写爬虫程序的时候由于要翻页,做除法分页的时候出现了 复制代码 代码如下: totalCount = '100' totalPage = int(totalCount)/20 Va...

python定时器(Timer)用法简单实例

本文实例讲述了python定时器(Timer)用法。分享给大家供大家参考。具体如下: # encoding: UTF-8 import threading #Timer(定时器)是T...

Python 迭代器工具包【推荐】

  原文:https://git.io/pytips   0x01 介绍了迭代器的概念,即定义了 __iter__() 和 __next__() 方法的对象,或者通过 yield 简化定...

tensorflow 重置/清除计算图的实现

调用tf.reset_default_graph()重置计算图 当在搭建网络查看计算图时,如果重复运行程序会导致重定义报错。为了可以在同一个线程或者交互式环境中(ipython/jupy...

python实现遍历文件夹修改文件后缀

本文实例为大家分享了python实现遍历文件夹修改文件后缀的具体代码,供大家参考,具体内容如下 用法 python Modifer.py ./ -fp java xml # codi...