String Methods

 0    48 fiche    sir
laste ned mp3 Skriv ut spille sjekk deg selv
 
spørsmålet svaret
Capitalizes first letter of string
begynn å lære
capitalize()
Returns a string padded with fillchar with the original string CENTERED to a total of width columns.
begynn å lære
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.
begynn å lære
count(str, beg = 0, end = len(string))
Decodes the string using the codec registered for encoding. encoding defaults to the default string encoding.
begynn å lære
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'.
begynn å lære
encode(encoding = 'UTF-8', errors = 'strict')
Expands tabs in string to multiple spaces
defaults to 8 spaces per tab if tabsize not provided.
begynn å lære
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.
begynn å lære
find(str, beg = 0 end = len(string))
Same as find(), but raises an exception if str not found.
begynn å lære
index(str, beg = 0, end = len(string))
Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise.
begynn å lære
isalnum()
Returns true if string has at least 1 character and all characters are alphabetic and false otherwise.
begynn å lære
isalpha()
Returns true if string contains only digits and false otherwise.
begynn å lære
isdigit()
Returns true if string has at least 1 cased character and all cased characters are in lowercase and false otherwise.
begynn å lære
islower()
Returns true if a unicode string contains only numeric characters and false otherwise.
begynn å lære
isnumeric()
Returns true if string contains only whitespace characters and false otherwise.
begynn å lære
isspace()
Returns true if string is properly "titlecased" and false otherwise.
begynn å lære
istitle()
Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise.
begynn å lære
isupper()
Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.
begynn å lære
join(seq)
Returns the length of the string
begynn å lære
len(string)
Returns a space-padded string with the original string left-justified to a total of width columns.
begynn å lære
ljust(width[, fillchar])
Converts all uppercase letters in string to lowercase.
begynn å lære
lower()
Removes all leading whitespace in string.
begynn å lære
lstrip()
Returns a translation table to be used in translate function.
begynn å lære
maketrans()
Returns the max alphabetical character from the string str.
begynn å lære
max(str)
Returns the min alphabetical character from the string str.
begynn å lære
min(str)
Replaces all occurrences of old in string with new or at most max occurrences if max given.
begynn å lære
replace(old, new [, max])
Same as find(), but search backwards in string.
begynn å lære
rfind(str, beg = 0, end = len(string))
Same as index(), but search backwards in string.
begynn å lære
rindex(str, beg = 0, end = len(string))
Returns a space-padded string with the original string right-justified to a total of width columns.
begynn å lære
rjust(width,[, fillchar])
Removes all trailing whitespace of string.
begynn å lære
rstrip()
Splits string according to delimiter str (space if not provided) and returns list of substrings
begynn å lære
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.
begynn å lære
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.
begynn å lære
startswith(str, beg=0, end=len(string))
Performs both lstrip() and rstrip() on string
begynn å lære
strip([chars])
Inverts case for all letters in string.
begynn å lære
swapcase()
Returns "titlecased" version of string, that is, all words begin with uppercase and the rest are lowercase.
begynn å lære
title()
Translates string according to translation table str(256 chars), removing those in the del string.
begynn å lære
translate(table, deletechars="")
Converts lowercase letters in string to uppercase.
begynn å lære
upper()
Returns original string leftpadded with zeros to a total of width characters
intended for numbers, it retains any sign given (less one zero).
begynn å lære
zfill (width)
Returns true if a unicode string contains only decimal characters and false otherwise.
begynn å lære
isdecimal()
Converts string into lower case
begynn å lære
casefold()
Returns True if the string is an identifier
begynn å lære
isidentifier()
Returns a tuple where the string is parted into three parts
begynn å lære
partition()
Splits the string at the specified separator, and returns a list
begynn å lære
rsplit()
Splits the string at the specified separator, and returns a list
begynn å lære
rsplit()
Returns a tuple where the string is parted into three parts
begynn å lære
partition()
Returns a tuple where the string is parted into three parts
begynn å lære
rpartition()
Removes prefix.
begynn å lære
. removeprefix()
Removes suffix.
begynn å lære
. removesuffix()

Du må logge inn for å legge inn en kommentar.