Python URL 参数自增:weekId 自动加一
在 Python 中,可以使用字符串的格式化方法来实现 URL 中 weekId 的自动递增。
url = 'https://hotel.wanzhuhu.com/guns-cloud-branch/signIn/signIn?branchId=10769&weekId={}'
week_id = 1925
# 第一次访问
print(url.format(week_id)) # https://hotel.wanzhuhu.com/guns-cloud-branch/signIn/signIn?branchId=10769&weekId=1925
# week_id 加一
week_id += 1
# 第二次访问
print(url.format(week_id)) # https://hotel.wanzhuhu.com/guns-cloud-branch/signIn/signIn?branchId=10769&weekId=1926
每次访问前,使用 url.format(week_id) 将 week_id 填入 URL 中,实现 week_id 的自增。
原文地址: https://www.cveoy.top/t/topic/mM0o 著作权归作者所有。请勿转载和采集!