Python:解释器如何读取设置和查找交集

时间:2016-05-17 07:25:12

标签: python set interpreter

我读到了 var rowSize = 100; var colSize = 100; var arr = new int[rowSize, colSize]; var r = new Random(); for (int i = 0; i < rowSize; i++) for (int j = 0; j < colSize; j++) arr[i, j] = r.Next(20); for (var subcol = 0; subcol < colSize / 10; subcol++) { for (var subrow = 0; subrow < colSize/10; subrow++) { var startX = subcol*10; var startY = subrow*10; var avg = 0; for (var x=0; x<10; x++) for (var y = 0; y < 10; y++) avg += arr[startX + x, startY + y]; avg /= 10*10; Console.WriteLine(avg); } }

 spawn ssh -t {*}$ssh_opts $user@$ip bash $script {*}$argv

我每次都会输出python setx = set(["a","b","c","d"]) y = set(["c","d"]) print( x.intersection(y) )

虽然它是正确的,但我对{'d', 'c'}

的序列感到好奇

解释器如何阅读集?

1 个答案:

答案 0 :(得分:1)

这种情况正在发生,因为set不像list那样维护订单。在这里查看此链接,以获得对不同Python结构的详细描述以及何时使用它们:https://stackoverflow.com/a/3489100/1199721