欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

python2和python3的不同点_Django python2和python3的区别

发布时间:2024/9/27 python 43 豆豆
生活随笔 收集整理的这篇文章主要介绍了 python2和python3的不同点_Django python2和python3的区别 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

查看django源码six.py,发现Django在python2和python3的区别:if PY3:

string_types = str,

integer_types = int,

class_types = type,

text_type = str

binary_type = bytes

MAXSIZE = sys.maxsize

else:

string_types = basestring,

integer_types = (int, long)

class_types = (type, types.ClassType)

text_type = unicode

binary_type = str

# 判断是不是Jython

if sys.platform.startswith("java"):

# Jython always uses 32 bits.

MAXSIZE = int((1 << 31) - 1)

else:

# It's possible to have sizeof(long) != sizeof(Py_ssize_t).

class X(object):

def __len__(self):

return 1 << 31

try:

len(X())

except OverflowError:

# 32-bit

MAXSIZE = int((1 << 31) - 1)

else:

# 64-bit

MAXSIZE = int((1 << 63) - 1)

del X

从代码可以看出Django在py2和py3区别还是挺明显

总结

以上是生活随笔为你收集整理的python2和python3的不同点_Django python2和python3的区别的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。