What's the most pythonic way to apply a function on every word in a string with multiple types of white space characters?

前端 未结 2 686
误落风尘
误落风尘 2021-01-24 11:04

Suppose I have a function

def f(a):
  return a[::-1]

I want to apply the function f to every word on a string. If the string consists only of s

2条回答
  •  甜味超标
    2021-01-24 11:34

    Use regular expressions, where you can easily get whole words and also whole chunks of continuous whitespace.

提交回复
热议问题