简体   繁体   中英

Assigning values Python 2D Array

I am just not getting this. I want to create a simple 2D array. I do not know the size, but it will be N number of rows of 3 columns. I have tried several things:

data_list[v_row][v_trade_date, v_buy_text, v_ticker]
data_list.append[v_trade_date, v_buy_text, v_ticker]
data_list[v_row].append(v_trade_date)
data_list[v_row].append(v_sell_text)
data_list[v_row].append(v_ticker)

Just not getting it. I do not need to use any FOR loop to assign the values, as each time through the outer loop, I'll be getting 3 items, and I'll assign them explicitly into different cells of that row. Maybe my thinking is wrong, and I'm thinking of 2D arrays from other languages, but any help would be great.

For appending a row:

data_list.append([v_trade_date, v_buy_text, v_ticker])

And for assigning:

data_list[v_row] = [v_trade_date, v_buy_text, v_ticker]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM