Python中的连接问题 [英] Concatenation question in Python
问题描述
有没有其他方法可以使用'for'或'while'条件来编码?
who = ['Gary','Kevin'] < br $> b $ b how_many = [12,34]
打印({}想要{}苹果。而{}想要{}橘子。格式(谁[0],how_many [0],谁[1],how_many [1]))
- >加里想要12个苹果。凯文想要34个橘子。
我尝试过:
who = ['Gary','Kevin']
how_many = [12,34]
打印({}想要{}苹果。{}想要{}橘子。。格式(谁[0],how_many [0],谁[1],how_many [1]))
- >加里想要12苹果。凯文想要34个橘子。
尝试字典: 5。数据结构 - Python 3.4.7rc1文档 [ ^ ]。
Is there any other way to code this by using 'for' or 'while' conditional?
who = ['Gary','Kevin']
how_many=[12, 34]
print("{} wants {} apples. And {} wants {}oranges.". format(who[0],how_many[0],who[1],how_many[1]))
-->Gary wants 12 apples. And Kevin wants 34 oranges.
What I have tried:
who = ['Gary','Kevin']
how_many=[12, 34]
print("{} wants {} apples. And {} wants {}oranges.". format(who[0],how_many[0],who[1],how_many[1]))
-->Gary wants 12 apples. And Kevin wants 34 oranges.
Try a Dictionary: 5. Data Structures — Python 3.4.7rc1 documentation[^].
这篇关于Python中的连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!