“Fungsi strip Python” Kode Jawaban

apa fungsi strip r dalam python

#!/usr/bin/python

str = "     this is string example....wow!!!     ";
print str.rstrip()
str = "88888888this is string example....wow!!!8888888";
print str.rstrip('8')

#the answer

#this is string example....wow!!!
#88888888this is string example....wow!!!
Poor Peccary

Fungsi strip Python

name = " softhunt.net "

print(name)

print(name.strip())
Outrageous Ostrich

string python: .strip ()

# Мөрний эхэн ба төгсгөлийн тэмдэгтүүдийг арилгахын тулд .strip() аргыг ашиглаж болно.
# Мөрийн аргументыг арга руу дамжуулж, арилгах тэмдэгтүүдийн багцыг зааж өгч болно.
# Аргын аргумент байхгүй бол хоосон зай арилна.

text1 = '   apples and oranges   '
text1.strip()       # => 'apples and oranges'
 
text2 = '...+...lemons and limes...-...'
 
# Here we strip just the "." characters
text2.strip('.')    # => '+...lemons and limes...-'
 
# Here we strip both "." and "+" characters
text2.strip('.+')   # => 'lemons and limes...-'
 
# Here we strip ".", "+", and "-" characters
text2.strip('.+-')  # => 'lemons and limes'
Puzzled Porcupine

Contoh fungsi strip Python

name = 'softhunt.net'
print(name)

strip_string = 'net'

print(name.strip(strip_string))
Outrageous Ostrich

Contoh sederhana fungsi strip Python

string = "softhunt.net"

print(string)

print(string.strip())

print(string.strip('softhunt'))
Outrageous Ostrich

Jawaban yang mirip dengan “Fungsi strip Python”

Pertanyaan yang mirip dengan “Fungsi strip Python”

Lebih banyak jawaban terkait untuk “Fungsi strip Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya