String Methods

 0    48 fiche    sir
Télécharger mP3 Imprimer jouer consultez
 
question réponse
Capitalizes first letter of string
commencer à apprendre
capitalize()
Returns a string padded with fillchar with the original string CENTERED to a total of width columns.
commencer à apprendre
center(width, fillchar)
Counts how many times str occurs in string or in a substring of string if starting index beg and ending index end are given.
commencer à apprendre
count(str, beg = 0, end = len(string))
Decodes the string using the codec registered for encoding. encoding defaults to the default string encoding.
commencer à apprendre
decode(encoding = 'UTF-8', errors = 'strict')
Returns encoded string version of string
on error, default is to raise a ValueError unless errors is given with 'ignore' or 'replace'.
commencer à apprendre
encode(encoding = 'UTF-8', errors = 'strict')
Expands tabs in string to multiple spaces
defaults to 8 spaces per tab if tabsize not provided.
commencer à apprendre
expandtabs(tabsize = 8)
Determine if str occurs in string or in a substring of string if starting index beg and ending index end are given returns index if found and -1 otherwise.
commencer à apprendre
find(str, beg = 0 end = len(string))
Same as find(), but raises an exception if str not found.
commencer à apprendre
index(str, beg = 0, end = len(string))
Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise.
commencer à apprendre
isalnum()
Returns true if string has at least 1 character and all characters are alphabetic and false otherwise.
commencer à apprendre
isalpha()
Returns true if string contains only digits and false otherwise.
commencer à apprendre
isdigit()
Returns true if string has at least 1 cased character and all cased characters are in lowercase and false otherwise.
commencer à apprendre
islower()
Returns true if a unicode string contains only numeric characters and false otherwise.
commencer à apprendre
isnumeric()
Returns true if string contains only whitespace characters and false otherwise.
commencer à apprendre
isspace()
Returns true if string is properly "titlecased" and false otherwise.
commencer à apprendre
istitle()
Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise.
commencer à apprendre
isupper()
Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.
commencer à apprendre
join(seq)
Returns the length of the string
commencer à apprendre
len(string)
Returns a space-padded string with the original string left-justified to a total of width columns.
commencer à apprendre
ljust(width[, fillchar])
Converts all uppercase letters in string to lowercase.
commencer à apprendre
lower()
Removes all leading whitespace in string.
commencer à apprendre
lstrip()
Returns a translation table to be used in translate function.
commencer à apprendre
maketrans()
Returns the max alphabetical character from the string str.
commencer à apprendre
max(str)
Returns the min alphabetical character from the string str.
commencer à apprendre
min(str)
Replaces all occurrences of old in string with new or at most max occurrences if max given.
commencer à apprendre
replace(old, new [, max])
Same as find(), but search backwards in string.
commencer à apprendre
rfind(str, beg = 0, end = len(string))
Same as index(), but search backwards in string.
commencer à apprendre
rindex(str, beg = 0, end = len(string))
Returns a space-padded string with the original string right-justified to a total of width columns.
commencer à apprendre
rjust(width,[, fillchar])
Removes all trailing whitespace of string.
commencer à apprendre
rstrip()
Splits string according to delimiter str (space if not provided) and returns list of substrings
commencer à apprendre
split(str="", num=string. count(str))
split into at most num substrings if given.
Splits string at all (or num) NEWLINEs and returns a list of each line with NEWLINEs removed.
commencer à apprendre
splitlines(num=string. count('\n'))
Determines if string or a substring of string (if starting index beg and ending index end are given) starts with substring str
returns true if so and false otherwise.
commencer à apprendre
startswith(str, beg=0, end=len(string))
Performs both lstrip() and rstrip() on string
commencer à apprendre
strip([chars])
Inverts case for all letters in string.
commencer à apprendre
swapcase()
Returns "titlecased" version of string, that is, all words begin with uppercase and the rest are lowercase.
commencer à apprendre
title()
Translates string according to translation table str(256 chars), removing those in the del string.
commencer à apprendre
translate(table, deletechars="")
Converts lowercase letters in string to uppercase.
commencer à apprendre
upper()
Returns original string leftpadded with zeros to a total of width characters
intended for numbers, it retains any sign given (less one zero).
commencer à apprendre
zfill (width)
Returns true if a unicode string contains only decimal characters and false otherwise.
commencer à apprendre
isdecimal()
Converts string into lower case
commencer à apprendre
casefold()
Returns True if the string is an identifier
commencer à apprendre
isidentifier()
Returns a tuple where the string is parted into three parts
commencer à apprendre
partition()
Splits the string at the specified separator, and returns a list
commencer à apprendre
rsplit()
Splits the string at the specified separator, and returns a list
commencer à apprendre
rsplit()
Returns a tuple where the string is parted into three parts
commencer à apprendre
partition()
Returns a tuple where the string is parted into three parts
commencer à apprendre
rpartition()
Removes prefix.
commencer à apprendre
. removeprefix()
Removes suffix.
commencer à apprendre
. removesuffix()

Vous devez vous connecter pour poster un commentaire.