易截截图软件、单文件、免安装、纯绿色、仅160KB

求助python,map filter

map,filter方法应该会返回一个列表。
但是在我这里,它们总是返回:
<map object at 0x0000000002A2C978>
<filter object at 0x0000000002A2C9E8>

我用的python3.1, 这个也是版本的变动导致的吗?

def map_func(lis):
  return lis + 1
li = [1,2,3,4,5]
map_l = map(map_func, li) #将li中所有的数都+1
print (map_l)

就是这个小程序,怎么加print?

看看这个
What's New In Python 3.0 http://blog.csdn.net/t_huanghai/archive/2008/12/04/3443782.aspx
里面有对python3.0 map()函数介绍,参考下 ,试试 print list(map_l)

map() and filter() return iterators. If you really need a list, a quick fix is e.g. list(map(...)), but a better fix is often to use a list comprehension (especially when the original code uses lambda), or rewriting the code so it doesn’t need a list at all. Particularly tricky is map() invoked for the side effects of the function; the correct transformation is to use a regular for loop (since creating a list would just be wasteful). 


What's New In Python 3.0

invalid syntax
看来,应该照它说的, 用for loop


谢谢小康

print (list(map_l))

correct format. mark it.


相关问答:

IIS 7 python 2.6 cgi 文件上传问题

我每次上传的文件读到的数据都不正确。2M 的图片读得10多K 。。哪位大侠可以帮帮我啊。
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......

PYTHON 一个程序,23行有错,不明白为什么 敬请指教!

Python code:

class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def paint(self, factory):
point = factory.getPoint()
......

python list for 循环问题

Python code:

p=[1,2,3,4,5,6]
while True:
for i in p:
if i==4:
p=[]
f=[9,8,7]
p.extend(f)
break
print i,',',
p. ......

Python抓包和包解析代码的编写

哪位前辈可以给我个Python写的【可运行的源代码】,实现以下功能:
  1.对指定端口的监听并截取【指定】数据包
  2.能对【自己定义的】协议包进行解析
万分感谢!!!

我来顶 thy38
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号