Notes icon indicating copy to clipboard operation
Notes copied to clipboard

py的"列表生成式"语法

Open any86 opened this issue 2 years ago • 0 comments

c = [i*2 for i in [3,21,67]]
print(c)
# [6, 42, 134]

"[]"里分2部分,后面的循环决定数组内容的长度, 前面是数组每一位的内容.

any86 avatar Jun 30 '22 05:06 any86