Python 字符串排序 | 字符串翻转

xiaoxiao2021-02-28  139

1. 排序 string = "orange" char_list = sorted(string) #已排序,以字符存在列表中 sorted_string = "".join(char_list) #将所有字符连起来 print sorted_string

2. 翻转

string = "abcde" print string[::-1]

转载请注明原文地址: https://www.6miu.com/read-39579.html

最新回复(0)