Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.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 2.7 按字典顺序排列电话号码_Python 2.7 - Fatal编程技术网

Python 2.7 按字典顺序排列电话号码

Python 2.7 按字典顺序排列电话号码,python-2.7,Python 2.7,在Python 2中,如何按字典顺序排列一大组数字(大约500个)。我的数字集如下所示: 09187788329 02043714140 06751292887 02892175534 04188296506 08279960090 05548958250 03590573588 所需输出的格式如下: 02043714140 02892175534 03590573588 04188296506 05548958250 06751292887 08279960090 09187788329调用P

在Python 2中,如何按字典顺序排列一大组数字(大约500个)。我的数字集如下所示: 09187788329 02043714140 06751292887 02892175534 04188296506 08279960090 05548958250 03590573588

所需输出的格式如下: 02043714140 02892175534 03590573588 04188296506 05548958250 06751292887 08279960090
09187788329

调用Python的
sorted
内置函数,在您的一个电话号码列表中进行排序

phone = (
  "09187788329 02043714140 06751292887 02892175534 "
  "04188296506 08279960090 05548958250 03590573588"
)

print (
  " ".join(
    sorted(
      phone.split(" ")
    )
  )
)