这里用到了
os.path.splitext()
和
os.path.split()
。
函数 | 作用 | 返回值 |
| 分割文件名和扩展名 | 元组 |
| 分割路径和文件名 | 元组 |
例子:
import os
url = "http://file.iqilu.com/custom/new/v2016/images/logo.png"
(file, ext) = os.path.splitext(url)
print(file)
print(ext)
(path, filename) = os.path.split(url)
print(filename)
print(path)
