2014-01-31 06:16:47 +00:00
|
|
|
print("".strip())
|
|
|
|
print(" \t\n\r\v\f".strip())
|
|
|
|
print(" T E S T".strip())
|
|
|
|
print("abcabc".strip("ce"))
|
|
|
|
print("aaa".strip("b"))
|
|
|
|
print("abc efg ".strip("g a"))
|
2014-04-26 03:20:08 +00:00
|
|
|
|
|
|
|
print(' spacious '.lstrip())
|
|
|
|
print('www.example.com'.lstrip('cmowz.'))
|
|
|
|
|
|
|
|
print(' spacious '.rstrip())
|
|
|
|
print('mississippi'.rstrip('ipz'))
|
2014-05-11 10:17:29 +00:00
|
|
|
|
|
|
|
print(b'mississippi'.rstrip(b'ipz'))
|
|
|
|
try:
|
|
|
|
print(b'mississippi'.rstrip('ipz'))
|
|
|
|
except TypeError:
|
|
|
|
print("TypeError")
|
|
|
|
try:
|
|
|
|
print('mississippi'.rstrip(b'ipz'))
|
|
|
|
except TypeError:
|
|
|
|
print("TypeError")
|
2014-05-30 00:07:05 +00:00
|
|
|
|
|
|
|
# single-char subj string used to give a problem
|
|
|
|
print("a".strip())
|
|
|
|
print("a".lstrip())
|
|
|
|
print("a".rstrip())
|
|
|
|
print(" a".strip())
|
|
|
|
print(" a".lstrip())
|
|
|
|
print(" a".rstrip())
|
|
|
|
print("a ".strip())
|
|
|
|
print("a ".lstrip())
|
|
|
|
print("a ".rstrip())
|
2014-05-30 00:11:44 +00:00
|
|
|
|
2017-09-19 18:19:23 +00:00
|
|
|
# \0 used to give a problem
|
|
|
|
|
|
|
|
print("\0abc\0".strip())
|
|
|
|
print("\0abc\0".lstrip())
|
|
|
|
print("\0abc\0".rstrip())
|
|
|
|
print("\0abc\0".strip("\0"))
|
|
|
|
|
2014-05-30 00:11:44 +00:00
|
|
|
# Test that stripping unstrippable string returns original object
|
|
|
|
s = "abc"
|
|
|
|
print(id(s.strip()) == id(s))
|