我需要删除URL中的最后一个“ 1”,以便可以在我的代码中实现它。 python中是否有任何方法可以删除“ 1”?
答案 0 :(得分:2)
a= "https://www.amazon.com/I3565-A453BLK-PUS-Dell-Laptop-Dual-Core-Processor/product-reviews/B07BLPHRX9/ref=cm_cr_arp_d_viewopt_srt?ie=UTF8&reviewerType=all_reviews&filterByStar=positive&pageNumber=1&sortBy=recent"
b= a.replace("pageNumber=1","pageNumber=")
print(b)
这是您的操作方式。使用string.replace()替换字符串中的任何内容。