ถอดเสื้อผ้าอยู่ในปลั๊กอินสำหรับไพธอน
txt = " banana "
x = txt.strip()
#x will be "banana"
ถอดเสื้อผ้าอยู่ในปลั๊กอินสำหรับไพธอน
txt = " banana "
x = txt.strip()
#x will be "banana"
ถอดปลั๊กอินสำหรับไพธอน
# removes outside whitespace/characters
' hey '.strip() # "hey"
' hey '.lstrip() # "hey "
' hey '.rstrip() # " hey"
'_.hey__'.strip('._') # "hey"
ถอดปลั๊กอินสำหรับไพธอน
# removes outside whitespace/characters
' hey '.strip() # "hey"
' hey '.lstrip() # "hey "
' hey '.rstrip() # " hey"
'_.hey__'.strip('._') # "hey"
ปลั๊กอินสำหรับไพธอนถอดเสื้อผ้าตัวอักษร
# Python3 program to demonstrate the use of
# strip() method
string = " python strip method test "
# prints the string without stripping
print(string)
# prints the string by removing leading and trailing whitespaces
print(string.strip())
# prints the string by removing strip
print(string.strip(' strip'))
Output:
python strip method test
python strip method test
python method test
ถอดเสื้อผ้า()
txt = ",,,,,rrttgg.....banana....rrr"
x = txt.strip(",.grt")
#outputs banana
print(x)
ปลั๊กอินสำหรับไพธอนเธอ()
a = " smurf "
a = a.strip()
#remove space at begining and end of string
print(a)
#smurf
.ถอดเสื้อผ้า()เป็นภาษาไพธอน
string = ' xoxo love xoxo '
# Leading and trailing whitespaces are removed
print(string.strip())
# All <whitespace>,x,o,e characters in the left
# and right of string are removed
print(string.strip(' xoe'))
# Argument doesn't contain space
# No characters are removed.
print(string.strip('stx'))
string = 'android is awesome'
print(string.strip('an'))