第27092题 单选题
下列关于Python中map高阶函数的代码运行结果与特性描述,正确的是?

已知如下两段Python代码:

# 代码1
nums = [1, 2, 3]
res = map(lambda x: x + 1, nums)
print(res)
# 代码2
nums = [1, 2, 3]
res = list(map(lambda x: x + 1, nums))
print(res)

请根据上述代码选择正确的说法:

A

代码1的输出结果为 [2, 3, 4]

B

代码2的输出结果为 [2, 3, 4]

C

map函数的第一个参数必须是匿名函数(lambda表达式)

D

map函数会直接返回一个包含所有计算结果的列表

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析