Python Forum
One silly stripping func to complement the lib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
One silly stripping func to complement the lib
#1
Another silly function I use often...
(I got an extention module with functions not in python lib.)

Stripping a bunch of caracters from a string.

Cool

def strStripAll(s,ss):
    return ''.join([c for c in s if c not in ss])


s = 'q werty  1234567890'
ss1 = strStripAll(s,' ')
ss2 = s.replace(' ','')

ss3 = strStripAll(s,'')
ss4 = strStripAll(s,'97 w')
ss5 = s.replace('97 w','')
ss6 = s.replace('9','').replace('7','').replace(' ','').replace('w','')

#lol
Reply


Messages In This Thread
One silly stripping func to complement the lib - by voidptr - Oct-03-2020, 09:14 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020