Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.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 我可以在Jython中使用from\uuuuuu future\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu?_Python_Jython_Sorted - Fatal编程技术网

Python 我可以在Jython中使用from\uuuuuu future\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu?

Python 我可以在Jython中使用from\uuuuuu future\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu?,python,jython,sorted,Python,Jython,Sorted,在我正在使用的机器上,我一直在使用Jython的旧版本(2.2.1),但我需要排序方法。我已经从未来导入了发电机,但是 from __future__ import sorted 返回SyntaxError:未定义已排序的未来功能。是否有一个模块我可以导入它?如果您使用的是旧版本的jython,也许您应该使用.sort() >>> a = [ 3, 1, 4, 1, 5, 9 ] >>> a.sort() >>> a [1, 1, 3, 4

在我正在使用的机器上,我一直在使用Jython的旧版本(2.2.1),但我需要排序方法。我已经从未来导入了发电机,但是

from __future__ import sorted

返回SyntaxError:未定义已排序的未来功能。是否有一个模块我可以导入它?

如果您使用的是旧版本的jython,也许您应该使用
.sort()

>>> a = [ 3, 1, 4, 1, 5, 9 ]
>>> a.sort()
>>> a
[1, 1, 3, 4, 5, 9]
您甚至可以定义自己的排序以替换缺少的排序:

>>> def my_sorted(a):
...     a = list(a)
...     a.sort()
...     return a
... 
>>> b = [3,1,4,1,5,9]
>>> my_sorted(b)
[1, 1, 3, 4, 5, 9]
>>> b
[3, 1, 4, 1, 5, 9]

2.2.1
?天哪。花时间升级Jython,而不是使用旧版本进行黑客攻击。仅供参考,这是将来可以导入的内容: