开发者

Get filename when using urllib.urlopen

开发者 https://www.devze.com 2023-01-19 10:29 出处:网络
I\'m using urllib.urlopen to read a file from a URL. What is the best way to get the filename? Do servers always return the Content-Dispo开发者_如何学JAVAsition header?

I'm using urllib.urlopen to read a file from a URL. What is the best way to get the filename? Do servers always return the Content-Dispo开发者_如何学JAVAsition header?

Thanks.


It's an optional header, so no. See if it exists, and if not then fall back to checking the URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消