美文网首页
python倒序排列字符串里的单词

python倒序排列字符串里的单词

作者: Xeroo | 来源:发表于2018-03-01 23:57 被阅读0次
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import re
phone = "aaa bbb ccc AAA BBB CCC"
g = re.compile(r'([a-z]+)',re.I)#生成用来提取字母正则表达式对象 re.I忽略大小写
temp = g.findall(phone)
temp.reverse()#倒序排列
string = ''
for b in range(len(temp)):
    string = string + ' ' + temp[b]
print string

相关文章

网友评论

      本文标题:python倒序排列字符串里的单词

      本文链接:https://www.haomeiwen.com/subject/omkoxftx.html