首页 > 编程语言 > 详细

Python2与Python3的区别收集

时间:2017-10-16 01:16:56      阅读:278      评论:0      收藏:0      [点我收藏+]

1、python2中,在列表推导中for关键字之后的赋值操作可能会影响到列表推导上下文中的同名变量:

Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> x=‘aaa‘
>>> test = [x for x in ‘ABC‘]
>>> x
‘C‘

 

python3:

>>> x=‘aaa‘
>>> test = [x for x in ‘ABC‘]
>>> x
‘aaa‘

 

Python2与Python3的区别收集

原文:http://www.cnblogs.com/nemolmt/p/7675125.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!