map(int, ..) 与 int() 的区别

>>> map(int,'0')
[0]
>>> int('-1')
-1
>>> map(int, l[1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '.'
>>> map(int, '-1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '-'
>>> map(int, '1.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '.'
>>> int('1.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.0'
>>> map(int, ['1.0'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.0'
>>> map(int, ['-1'])
[-1]

 

posted @ 2015-01-28 00:40  monlh  阅读(2364)  评论(0编辑  收藏  举报