python - How do I implement rstrip for arbitrary strings? -
Say I have a bunch of strings, which either end in For example, suppose that was my input then the output should be code> then . Simply join the end anchor at the end of your expression and make it only at the end. (I have left any additional pineapple,
ham May be , or
grapes . What is the best way to prepare a list of "hidden stars", which is fine as the original stars, if only the
pineapple is finished, then
pineapple Will be trimmed by the end, and if the string ends with
ham , then
ham will be trimed?
["I really like pineapple", "I do not like hem or grapes", "Today I ate "a lot of hams," but I eat many grapes "]
[" I really like " , "I do not like hem or grapes", "I ate a lot today", "but I ate too many grapes"]
import re stuff = ["I really like pineapple", "I don" like hem or grapes "," I ate a lot today "," but I have so many grapes Eat "] [Re: ('' Pineapple Hamm) $ '', '', S) (in accessories for) [7]: ['I really like', 'I do not like hem or grapefruit' 'I have eaten a lot today', but I eat many grapes']
strip To clean white space
re.sub ('{}} $' will do this with arbitrary list of stars to do this: Format ('.' .join (arbitrary_list_of_strings)), '', s) ...
Comments
Post a Comment