请问如何用python循环语句生成以下数组?
urls = [
    'https://test.test.cn/users/20000',
    'https://test.test.cn/users/20001',
    'https://test.test.cn/users/20002',
    'https://test.test.cn/users/20003',
    'https://test.test.cn/users/20004',
    'https://test.test.cn/users/20005',
    'https://test.test.cn/users/20006',
    'https://test.test.cn/users/20007',
    'https://test.test.cn/users/20008',
    'https://test.test.cn/users/20009',
    'https://test.test.cn/users/20010',
    'https://test.test.cn/users/20011',
    'https://test.test.cn/users/20012',
    'https://test.test.cn/users/20013',
    'https://test.test.cn/users/20014',
    'https://test.test.cn/users/20015',
    'https://test.test.cn/users/20016',
]

2个回答

urls = [ 'https://test.test.cn/users/'+str(i) for i in range(20000,20017)]

# coding:UTF-8
TEMPLATE = "https://test.test.cn/users/"
urls = list()
for i in range(20000, 20016):
    url = TEMPLATE + str(i)
    urls.append(url)
print urls
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问