你好,我想一举得到两个清单
我想在字符串中列出一个名字列表,另一个数字列表:
for i,j in map(None,[school,phonenumber]):
phrase = "{} : {}".format(i,j)
complete.append(phrase)
学校和电话号码是列表,但我不知道如何获取每一行的索引
import csv
import pandas as pd
f = open('phone.csv')
phonenumber = list(csv.reader(f))
f = open("school2.csv", "r")
school = list(csv.reader(f))
complete = []
for i,j in map(None,[school,phonenumber]):
phrase = "{} : {}".format(i,j)
complete.append(phrase)
print(complete)
我已经尝试过了,不知道哪里出问题了
我只想上学:电话号码...。
谢谢您的帮助!
答案 0 :(得分:0)
尝试一下, 您需要zip。
for i,j in zip(school,phonenumber):
phrase = "{} : {}".format(i,j)
complete.append(phrase)
答案 1 :(得分:0)
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute是您要寻找的
for i,j in zip(school,phonenumber):