def __init__(self, data=None, dim=None, init_value=0):
if data != None: # 输入data不为空的情况
self.data = data
self.dim = (len(data), len(data[0]))
elif dim == None: # data和dim全为空的情况
raise ValueError("data和dim不能全为None")
else: # data为空,dim和init_value决定矩阵的情况
self.data = [[init_value for column_num in range(0, dim[1])] for row_num in range(0, dim[0])]|
self.dim = dim```
What I want the code to look like after pressing `enter`:
```python
def __init__(self, data=None, dim=None, init_value=0):
if data != None: # 输入data不为空的情况
self.data = data
self.dim = (len(data), len(data[0]))
elif dim == None: # data和dim全为空的情况
raise ValueError("data和dim不能全为None")
else: # data为空,dim和init_value决定矩阵的情况
self.data = [[init_value for column_num in range(0, dim[1])] for row_num in range(0, dim[0])]
self.dim = dim
|
What the code actually looks like after pressing enter:
def __init__(self, data=None, dim=None, init_value=0):
if data != None: # 输入data不为空的情况
self.data = data
self.dim = (len(data), len(data[0]))
elif dim == None: # data和dim全为空的情况
raise ValueError("data和dim不能全为None")
else: # data为空,dim和init_value决定矩阵的情况
self.data = [[init_value for column_num in range(0, dim[1])] for row_num in range(0, dim[0])]
self.dim = dim
|
What the code looks like before pressing
enter
:What the code actually looks like after pressing
enter
:before:
after: