Python-如何在二进制读取模式下打开远程文件? [英] Python - how to a open remote file in binary read mode?
本文介绍了Python-如何在二进制读取模式下打开远程文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用mutagen模块读取mp3
文件的元数据.问题在于模块期望使用本地mp3
文件,但是我的mp3
文件位于远程服务器上.
I'm trying to use the mutagen module to read the metadata of an mp3
file. The problem is that the module is expecting a local mp3
file, but my mp3
files are on a remote server.
这是模块中的行,当我发送远程mp3 URL作为第一个参数时会引发错误.
This is the line in the module that raises an error when I send a remote mp3 URL as the first parameter.
fp = file(f, "rb")
如何更改此行代码,以便它可以在rb mode
中打开远程文件(例如http://remotedomain.com/file.mp3
)?
How can I alter this line of code so that it can open a remote file (e.g. http://remotedomain.com/file.mp3
) in rb mode
?
推荐答案
fp = urllib2.urlopen("http://remotedomain.com/file.mp3")
默认为二进制模式
这篇关于Python-如何在二进制读取模式下打开远程文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文