【发布时间】:2021-02-18 02:30:36
【问题描述】:
我在 python 3 中创建了矩阵类(目前我只创建了一种方法):
class Matrix() :
__rows = []
__columns = []
def SetRows(self,rows) :
self.__rows = rows
i = 0
while i < len(rows[0]) :
a = []
j = 0
while j < len(rows) :
a.append(rows[j][i])
j += 1
self.__columns.append(a)
i += 1
m = Matrix
m.SetRows([[0,8,56],[98,568,89]])
但它给出了这个错误:
Traceback (most recent call last):
File "f:\PARSA\Programming\Python\2-11-2.py", line 14, in <module>
m.SetRows([[0,8,56],[98,568,89]])
TypeError: SetRows() missing 1 required positional argument: 'rows'
我输入了“行”参数。显然,我不需要输入“自我”。我将 VS Code 用于 IDE。感谢您的帮助。
【问题讨论】:
标签: python class methods arguments