“乘以”两个字符串列表

时间:2016-01-10 15:30:24

标签: python list concatenation

使用Python3.5 我有两个字符串列表,我想'乘以'这两个列表,所以我可以做一个ebay搜索carparts,并打印到控制台。

cars = ['ford focus', 'honda civic', 'chevy truck',]
parts = ['ignition', 'head light']

for car in cars:
    for part in parts:
        print(cars[car]) + parts[part])

预期产出:

>>>ford focus ignition
ford focus head light
honda civic ignition
honda civic head light
chevy truck ignition
chevy truck head light

我尝试了几种不同的方法,但似乎无法得到任何东西来给我我需要的输出。我试图使用numpy,但无法弄清楚如何安装它。在cmd的“pip install numpy”一直给我一些我无法弄清楚的错误。我需要将输出作为同一行上的两个字符串,因为我将它们复制并粘贴到记事本文档中,并利用该行的数据进行ebay搜索。

0 个答案:

没有答案
相关问题