Skip to content

Commit f86062c

Browse files
author
Spencer.Luo
committed
Modify Strategy.py
1 parent dec2748 commit f86062c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pattern/Strategy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ def testPersonListInPython():
177177
Person("Helen", 16, 45.7, 1.60)
178178
]
179179

180-
# 使用使用operator模块根据年龄进行排序
181-
print("根据年龄进行排序后的结果:")
180+
# 使用operator模块根据年龄、身高进行排序
182181
sortedPerons = sorted(personList, key = attrgetter('age'))
182+
sortedPerons1 = sorted(personList, key=attrgetter('height'))
183+
184+
print("根据年龄进行排序后的结果:")
183185
for person in sortedPerons:
184186
person.showMysef()
185187
print()
186-
187188
print("根据身高进行排序后的结果:")
188-
sortedPerons1 = sorted(personList, key=attrgetter('height'))
189189
for person in sortedPerons1:
190190
person.showMysef()
191191

@@ -198,8 +198,8 @@ def testPersonListInPython():
198198

199199

200200
# testTheDinner()
201-
testSortPerson()
202-
# testPersonListInPython()
201+
# testSortPerson()
202+
testPersonListInPython()
203203

204204

205205
# testArray()

0 commit comments

Comments
 (0)