Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of receiving parameters of Python map

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "case analysis of Python map receiving parameters". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "case analysis of Python map receiving parameters" can help you solve the problem.

Description

1. The map function takes two arguments, one is the function, and the other is Iterable.

2. Map acts on each element of the sequence in turn, and returns the result to the new Iterator.

Example

# map uses # to find the square of arr each element arr = [1,2,3,4,5,6,7,8] def square (x): return x * xresult = map (square, arr) print (list (result)) # lambda with map result1 = map (lambda x: X * x, arr) print (list (result1)) # lambda uses multiple parameters with map If the number of arr and arr1 is different, only the minimum number will be counted. If the number of arr1 is less than arr, only 5 elements will be returned. Otherwise, fewer arr will only calculate the number of arr digits arr1 = [1, 2, 3, 4, 5, 6] result2 = map (lambda x, y: X * x + y, arr, arr1) print (list (result2)). Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report