Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么Python中的set函数为相同的输入生成不同的输出?_Python_Python 3.x_Python Collections - Fatal编程技术网

为什么Python中的set函数为相同的输入生成不同的输出?

为什么Python中的set函数为相同的输入生成不同的输出?,python,python-3.x,python-collections,Python,Python 3.x,Python Collections,这是我的密码 string='AABCAAADA' k=3 对于范围内的i(0,len(字符串),k): 打印(设置(字符串[i:i+k])) 每次运行它都会产生不同的输出。我怎样才能解决这个问题? 产出: {'B', 'A'} {'A', 'C'} {'D', 'A'} 因为set() 也就是输出相同的集合。集合对象本质上是无序的。 {'B', 'A'} {'C', 'A'} {'D', 'A'} {'A', 'B'} {'A', 'C'} {'A', 'D'}

这是我的密码

string='AABCAAADA'
k=3
对于范围内的i(0,len(字符串),k):
打印(设置(字符串[i:i+k]))
每次运行它都会产生不同的输出。我怎样才能解决这个问题?
产出:

{'B', 'A'}
{'A', 'C'}
{'D', 'A'}
因为
set()

也就是输出相同的集合。集合对象本质上是无序的。
{'B', 'A'}
{'C', 'A'}
{'D', 'A'}
{'A', 'B'}
{'A', 'C'}
{'A', 'D'}