감동, 마음이 움직이는 것
[python] 정해진 사이즈의 2d list 만들기 본문
Tips (Utility, Computer Language, and etc.)
[python] 정해진 사이즈의 2d list 만들기
Struggler J. 2019. 1. 23. 06:10https://stackoverflow.com/questions/2397141/how-to-initialize-a-two-dimensional-array-in-python
How to initialize a two-dimensional array in Python?
x = [[0 for i in range(Nc)] for j in range(Nr)] #making Nr*Nc matrix (2d array)
In [1]: Nc = 5; Nr = 3
In [2]: x = [[0 for i in range(Nc)] for j in range(Nr)]
In [3]: x
Out[3]: [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
In [4]: x[1]
Out[4]: [0, 0, 0, 0, 0]
'Tips (Utility, Computer Language, and etc.)' 카테고리의 다른 글
[python] PCA and figure (0) | 2019.04.30 |
---|---|
[gnuplot] How to do horizontal lines from a one column file using gnuplot? (0) | 2019.01.28 |
[gnuplot] histogram 그리기 (0) | 2019.01.22 |
[python] numpy array sort inverse (0) | 2019.01.17 |
[linux] tar 압축하기 (0) | 2019.01.15 |