url 获取文件名
url="https://dldir1.qq.com/qqfile/qq/PCQQ9.6.2/QQ9.6.2.28756.exe"
filepath.Base(url)
filepath.Base(url) 就 为 QQ9.6.2.28756.exe
路径中获取 文件名
exePath := "C:\WINDOWS\system32\calc.exe"
fileNameWithExt := filepath.Base(exePath) // 获取带 扩展名 的名字
fileNameNoExt := strings.TrimSuffix(fileNameWithExt, filepath.Ext(exePath)) // 获取不带 扩展名 的名字
fileNameWithExt 为 calc.exe
fileNameNoExt 为 calc
评论 (0)