我想在列表中每个字符串的末尾添加数字。 示例:
a = ['a', 'b', 'c']
b = list(range(0, 3))
预期结果:
c = ['a0', 'a1', 'a2', 'b0', 'b1', 'b2', 'c0', 'c1', 'c2']
答案 0 :(得分:1)
使用列表理解-
router = DefaultRouter()
router.register('test', SampleViewset, base_name="test")
urlpatterns = [
path('admin/', admin.site.urls),
path('docs/', include_docs_urls(title='My API title', public=True)),
path('', include(router.urls)),
]
答案 1 :(得分:0)
尝试:
a = ['a', 'b', 'c']
b = list(range(0, 3))
b=[str(b1) for b1 in b]
out=[a1+b1 for (a1,b1) in list(product(a,b))]
out