python字符串按单词反转输出,python字符串反转,方法1import re
python字符串按单词反转输出,python字符串反转,方法1import re
方法1
import reastring = 'hello world'revwords = ' '.join(reversed(astring.split()))print(revwords)
方法2
import reastring = 'hello world'revwords = ''.join(reversed(re.split(r'(\s+)', astring)))print(revwords)
相关内容
- python判断字符串是否以指定的字符串结尾的函数endswi
- python链接字符串的几种方法,python几种方法,方法1:直
- python数组过滤方法,python数组过滤,li = ["a", "
- python比较两个列表的大小,python列表大小,L1 = [1, ('a
- python 中yield的用法详解,pythonyield,包含了关键字"yie
- python带模块里延迟导入名字,python模块,#!/usr/bin/e
- 在python脚本内运行linux命令,pythonlinux,#/usr/bin/en
- 一个简单python ftp客户端代码,pythonftp客户端,#!/usr/bin
- python字典复制演示代码,python字典演示,L = [1,2,3]D
- python获取数组元素个数,python获取数组,# Return the
评论关闭