我正在用Python编写数独解决程序。
我有class,内部类,列表,构造函数和功能,它们会使list成为行对象。
class Table:
rows = []
def __init__(self):
initRows()
class Row:
numbers = []
def __init__(self):
"stuff that stores a list of integers in **numbers** list"
def initRows(self, numbers):
for i in range(9):
temp_row = self.Row(i, numbers)
self.rows.append(temp_row)
程序如下所示:
[0, 0, 0, 7, 4, 0, 0, 0, 6]
[4, 0, 6, 8, 0, 0, 5, 0, 7]
[7, 0, 0, 0, 9, 0, 0, 0, 4]
[0, 3, 0, 9, 8, 4, 7, 0, 0]
[8, 2, 0, 6, 1, 3, 4, 0, 9]
[0, 4, 0, 0, 0, 0, 3, 0, 0]
[0, 6, 2, 3, 7, 0, 0, 0, 5]
[0, 0, 5, 4, 0, 9, 0, 0, 0]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
print()在
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
[0, 7, 0, 0, 6, 1, 2, 0, 8]
我在互联网上搜索小时,发现人们对列表类的append()函数有疑问,但没有帮助。所以我的问题是:我怎么做这项工作?我正在用Python编写数独解决程序。我有一个类,一个内部类,一个列表,构造函数和一个将构成Row对象列表的函数。类表:行= [] ...((如果需要其他信息/代码的一部分:请问!)
Row类)而不是instance属性。谢谢主席先生!