python
Python中怎么打印变量名?>>> 红桃=1
>>> 黑桃=2
>>> member=[黑桃,红桃]
>>> member
>>> member.sort()
>>> member
例如说在这个,我想打印member的显示结果为["红桃","黑桃"] 你的member和黑桃红桃并没有关系所以显示不出 你可以换个对象或者换一种数据结构来表达
>>> from collections import namedtuple
>>> Poker = namedtuple('Poker', ['数值', '花色'])
>>> 黑桃 = Poker(2,'黑桃')
>>> 红桃 = Poker(1,'红桃')
>>> member = [黑桃,红桃]
>>> member
>>> member.sort()
>>> member
>>>
kogawananari 发表于 2021-2-11 00:05
你的member和黑桃红桃并没有关系所以显示不出 你可以换个对象或者换一种数据结构来表达
好的,谢谢了
页:
[1]