# 蟒蛇 |刪除數組中每一行的最後一個元素

| |

` # Python3 代碼演示它是如何工作的 `
` # 刪除矩陣中每一行的最後一個元素 `
` # 使用a loop + Del + slicing list `

` # 初始化列表 `

` test_list ` ` = ` ` [[[` ` 1 ` `, ` ` 3 ` `, ` ` 4 ` `], [` ` 2 ` `, ` ` 4 ` `, ` ` 6 ` `], [` ` 3 ` `, 8 , 1 ] ] `

` # 打印原始列表 `

` print ( "原始列表：" + str (test_list)) `

` # 刪除每一行的最後一個元素在矩陣中 # 使用循環 + Del + slicing list `

` for ele in test_list: del ele [ - 1 ] `

` # 打印資源ult `

` print ( "去除後的矩陣行中的後元素：“ + str (test_list) ) `

`原始列表：[[1, 3, 4], [2, 4, 6] , [3, 8, 1]] 從行中移除後元素後的矩陣：[[1, 3], [2, 4], [ 3, 8]] `

` # Python3 代碼來演示它是如何工作的`

` # Python3 代碼 code> # 刪除矩陣每一行的最後一個元素 # 使用列表推導 + 列表切片 # 初始化列表 test_list = [[ 1 , 3 , 4 ], [ 2 , 4 , 6 ], [ 3 ， 8 , 1 ]] # 打印原始列表 print ( " 原始列表：" + str (test_list)) # 刪除矩陣中每一行的最後一個元素 # 使用列表推導 + 列表切片 res = [ele [: - 1 ] for ele in test_list] # 打印結果 print ( "去除行後元素後的矩陣：" + str (res)) `

`原始列表：[[1, 3, 4], [2, 4, 6], [3, 8, 1]] 從行中去除後元素後的矩陣：[[1 , 3], [2, 4], [3, 8]] `

Marie Danburry

Singapore | 2022-11-26

Davies Krasiko

Munchen | 2022-11-26

Julia OConnell

Prague | 2022-11-26

## Shop

Learn programming in R: courses

\$

Best Python online courses for 2022

\$

Best laptop for Fortnite

\$

Best laptop for Excel

\$

Best laptop for Solidworks

\$

Best laptop for Roblox

\$

Best computer for crypto mining

\$

Best laptop for Sims 4

\$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

NUMPYNUMPY

How to specify multiple return types using type-hints

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

NUMPYNUMPY

glob exclude pattern

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

NUMPYNUMPY

Python CSV error: line contains NULL byte

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically