python中list 转set和tuple遇到的坑

list 转set ,原顺序会变,而list转tuple原顺序不会变:

#!/usr/bin/env python
# -- coding: utf-8 --
# @Time : 2020-12-24 15:51
# @Author : wmy
# @File : __init__.py.py
#
x = (1, 8, 5)
print('set(x):{0}'.format(set(x)))
print('tuple(x): {0}'.format(tuple(x)))

result:

猜你喜欢

转载自blog.csdn.net/qq_36940806/article/details/111920028
今日推荐