在下面的代码中,可以有多个图A.对象;这些由输出中的小写字母表示。这些对象中的每一个都有一个名称字典和它们的键/值的特征(即。形状:圆形). 你知道吗
for objectsA in figureA.objects:
thisObjectA = figureA.objects[objectsA]
#print the objects lower-case letter (the shape's identifier)
print objectsA
for attributesA in thisObjectA.attributes:
#print the attribute's for the object name:characteristic
print attributesA, thisObjectA.attributes[attributesA]
输出为:
a
shape circle
fill no
size very large
b
shape plus
fill yes
angle 0
inside a
size small
如何创建新的字符串列表或仅创建值列表而不是打印?当然,小写字母a和b不包括在内。 维护顺序也很重要(a的属性,然后是b的属性,等等)
非常感谢您的帮助!你知道吗
从你的评论来看,你想要的是:
这将创建一个包含所有属性的列表并对它们进行排序
相关问题 更多 >
编程相关推荐