- Python中的str类型没有内置的排序函数,可通过以下方式:
string = "acbed"
str_list = sorted(string) # ['a', 'b', 'c', 'd', 'e']
string = " ".join(str_list) # "abcde"
- join函数为:
str.join(sequence)
''
以str为分隔符连接seqence序列中的元素
例如:"".join(['a', 'b', 'c']),为"abc"
"_".join(['a', 'b', 'c']),为"a_b_c"
''