简体   繁体   English

使用非拉丁字符串作为键的Python中的Tuple排序

[英]Sorting with Tuple in Python with non-Latin strings as keys

I have figured out how to sort list which return a tuple with false. 我已经弄清楚了如何排序返回false的元组的列表。 This key works when language is in English but won't work when translated to Japanese. 当语言为英语时,此键有效,但将其翻译为日文时,则无效。

key=lambda x:(x.name!='Iraq', x.name)

This one won't work. 这一个行不通。

key=lambda x:(x.name!='イラク', x.name)

Any idea about this? 有什么想法吗?

Add at the top of the file the following lines in order to support utf8: 在文件顶部添加以下行以支持utf8:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM