设立一个directions数组,存储方向,然后在满足条件的时候,转换方向,请注意当row或col到达边界的时候,或者当前遍历值已经“输出”过的时候,则转换方向。 # -*- coding:utf-8 -*- class Solution: # matrix类型为二维列表,需要返回列表 def printMatrix(self, matrix): # write code here directions=[(0,1),(1,0),(0,-1),(-1,0)] row= len(matrix) col=len(matrix[0]) result=[0]*(row*col) count=0 r=...