在这里您可以看到我已经添加了这段代码,但是我没有得到输出
worddictionary = {'kjnkn':4, 'efgrs':6, 'fgesgv':7}
a = list()
b = list()
c = list()
k = len(a)
for key, value in worddictionary.items():
a.append(key)
b.append(value)
for i in range(k):
c[i] = a[i] + '-' + b[i]
print(c[i])
答案 0 :(得分:0)
没有理由涉及所有这些列表。使用列表理解直接从c
生成worddictionary.items()
:
worddictionary = {'kjnkn':4, 'efgrs':6, 'fgesgv':7}
c = ["'{}'-{}".format(k, v) for k, v in worddictionary.items()]
for i in c:
print(i)