您已经快到了,只需要使用字符串格式即可:>>> ["{} ({})".format(x,y) for x,y in zip(Countries, Base)]['Germany (2005)', 'UK (1298)', 'France (1222)', 'Italy (3990)']用途str.join:>>> print ", ".join('"{} ({})"'.format(x,y) for x,y in zip(Countries, Base))"Ge...
Python provides different variable type for programmers usage. We can use int, float, string, list...
但是我的程序只能合并为如图, 姓名后的字符'\t' 不能显示,不知道哪里出错,另外用windows自带的记事本打开,内容只显示在一行,没有换行 程序代码如下 #! /usr/bin/env python3 # -*- coding: utf-8 -*- def toDic(_lines): dic = {} for line in _lines: #获取第一个文本中的 姓名和邮箱 信息 e...
我有两个清单:Countries = ["Germany", "UK", "France", "Italy"] Base = ["2005","1298",1222","3990"]预期结果:"Germany (2005)", "UK (1298)", "France (1222)", "Italy (3990)"我的剧本:zipped = zip(Countries, Base)结果:[('Germany', '2005')", ('UK', '1298'), ('France',...