作者StubbornLin (Victor)
看板Python
标题Re: [问题] 忘了一个东西
时间Thu Jan 10 21:18:41 2008
※ 引述《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