ถอดเสื้อผ้าอยู่ในปลั๊กอินสำหรับไพธอน

รหัสตัวอย่าง

22
0

ถอดเสื้อผ้าอยู่ในปลั๊กอินสำหรับไพธอน

txt = "     banana     "
x = txt.strip()
#x will be "banana"
14
0

ถอดปลั๊กอินสำหรับไพธอน

# removes outside whitespace/characters
'  hey  '.strip()     # "hey"
'  hey  '.lstrip()    # "hey  "
'  hey  '.rstrip()    # "  hey"
'_.hey__'.strip('._') # "hey"
12
0

ปลั๊กอินสำหรับไพธอนถอดเสื้อผ้าตัวอักษร

# 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
9
0

ถอดปลั๊กอินสำหรับไพธอน

txt = "  test    "

txt.strip()
#Output: "test"

txt.lstrip()
#Output: "test    "

txt.rstrip()
#Output: "  test"
6
0

ถอดเสื้อผ้า()

txt = ",,,,,rrttgg.....banana....rrr"
x = txt.strip(",.grt")
#outputs banana
print(x)
0
0

ถอดเสื้อผ้าฟังก์ชันภาษาไพธอน

lol = '     lol   '
print(lol)
# normal output =      lol   
lol = '     lol    ' 
print(lol.strip())
# strip output = lol
# Cool right

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังหน้ากับตัวอย่างอยู่ในหมวดหมู่