AHA๐Ÿ‘Œ python - map , ๋ฆฌ์ŠคํŠธ-> ๋ฌธ์ž์—ด : join

SeomIIIยท2021๋…„ 7์›” 13์ผ
0

AHA๐Ÿ‘Œ

๋ชฉ๋ก ๋ณด๊ธฐ
1/14
post-thumbnail

map

  • map(f,iterable) : ํ•จ์ˆ˜(f) ์™€ ๋ฐ˜๋ณต๊ฐ€๋Šฅํ•œ (iterable) ์ž๋ฃŒํ˜•์„ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์Œ.
def test (numberList):
	result=[]
    for number in numberList:
    	result.append(number*2)
    return result
>> list(map(test,[1,2,3,4]))
>> list(map(lambda a:a*2, [1,2,3,4]))

๋ฆฌ์ŠคํŠธ --> ๋ฌธ์ž์—ด

: ๋ฆฌ์ŠคํŠธ ๋ฐฐ์—ด์ด ๋ชจ๋‘ ๋ฌธ์ž์—ด์ด์–ด์•ผํ•จ.
๋งŒ์•ฝ ๋ฆฌ์ŠคํŠธ ๋ฐฐ์—ด์ด ์ •์ˆ˜ํ˜•์ผ ๊ฒฝ์šฐ ๋ฆฌ์ŠคํŠธ ์ •์ˆ˜ํ˜•์„ ๋ฆฌ์ŠคํŠธ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ ํ›„ ๋ฌธ์ž์—ด๋กœ ๋ฐ”๊พผ๋‹ค.

a=['1','2','3']
string=''.join(a)
b=[1,2,3]
print(''.join(str(_) for _ in b))
profile
FE Programmer

0๊ฐœ์˜ ๋Œ“๊ธ€