Re: [問題] 忘了一個東西
※ 引述《StubbornLin (Victor)》之銘言:
: ※ 引述《huggie (huggie)》之銘言:
: def echo(s):
: print s
: a = [1,2,3,4]
: [echo(item) for item in a]
: map(echo, a)
: 像這樣嗎? 不過print好死不死好像不能當成lambda
from sys import stdout
a = [1,2,3,4]
# method 1
[stdout.write(item) for item in a]
# method 2
map(stdout.write, a)
改了一下,不用print改用直拿stdout來write就可以了
--
VICTOR工作室 http://www.kinmen.info/vic/
程式設計教學 http://victorlin.serveftp.org/programming/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.231.218.77
討論串 (同標題文章)
Python 近期熱門文章
PTT數位生活區 即時熱門文章