Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet99/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   95   96   97   98   99   100   101   102   ...   453
80

CHAPTER 5
InteractIng wIth StructureS and ObjectS
Performing Standard Tasks with Strings
You’ve already seen a few of the things you can do with strings in previous chapters. This chapter 
takes a little more organized look at the methods and properties associated with strings. The following 
list provides an overview of the most common tasks you can perform.
➤➤
center(int width[, Char fillchar])
: Centers the string within the space defined by 
width

The default is to use spaces to pad the left and right side of the string to center it. However, you 
can specify another character by specifying the optional 
fillchar
. For example, if you want to 
center a string named MyString in a 40-character area using the * as a fill character, you’d type 
MyString.center(40, ‘*‘)
.


int count(str ssub, [int start[, int end]])
: Counts the number of instances of 
a substring, 
ssub
, within a string. The substring can be one or more letters that you want 
to find within the string. You may optionally provide a starting point, 
start
, and an end-
ing point, 
end
, for the count. For example, if you want to count the number of ls found in 
MyString
, you’d type 
MyString.count(‘l‘, 0, len(MyString))
.


decode([object encoding[, str errors]])
: Decodes an encoded string. Even
though 
encoding
is optional, you must provide a value in order to decode the string.
You can find a list of standard encodings at 
http://www.python.org/doc/2.5.2/lib/
standard-encodings.html
. The errors argument defines how 
decode()
treats errors, 
with a default value of 
strict
. You can find a list of error strings at 
http://www.python 
.org/doc/2.5.2/lib/codec-base-classes.html
. For example, you might have a Unix-
to-Unix Encode (uuencode) string named EncodeString that you want to decode into plain 
text. To convert the string, you’d type 
EncodeString.decode(‘uu_codec‘)
.



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   95   96   97   98   99   100   101   102   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish