for构建多网址列表简写

urls=[
    f"https://www.cnblogs.com/sitehome/p/{page}"
    for page in range(1,5+1)
]
print(urls)

['https://www.cnblogs.com/sitehome/p/1', 'https://www.cnblogs.com/sitehome/p/2', 'https://www.cnblogs.com/sitehome/p/3', 'https://www.cnblogs.com/sitehome/p/4', 'https://www.cnblogs.com/sitehome/p/5']
posted @ 2021-12-19 11:24  晨光曦微  阅读(24)  评论(0编辑  收藏  举报