我想删除某些URL的最后一部分。例如:http://localhost/browser/Folder/Folder2/Folder3/the%20end%20xd.txt应该变成http://localhost/browser/Folder/Folder2/Folder3。我如何轻松删除最后一个斜杠及其后的部分?
答案 0 :(得分:0)
您可以尝试
url = "http://localhost/browser/Folder/Folder2/Folder3/the%20end%20xd.txt"
url = url[:url.rfind('/')]