Str

41 tutorials Updated 18 Apr 2021

  1. 1 capitalize() in Python The capitalize() method of str class in Python returns a copy of the string that has its first letter capitalised and all other letters made to lower case. 9 Mar 2017
  2. 2 casefold() method of str class in Python The str.casefold() method in Python returns a casefolded copy of the original string. The normalization used in casefold() is much aggressive and original representation may not be preserved. 20 Nov 2018
  3. 3 center() method - string class center() method of string class in Python places the original string, in a string of specified width. Both sides of new string will have padded characters. 9 Mar 2017
  4. 4 count() function of str class The count function of str class in Python returns the number of time a substring occurs in a given string.Start and stop positions can be specified. 10 Mar 2017
  5. 5 encode() method of str class in Python The encode() method of the string class in Python returns the code points of a string encoded as bytes. The default encoding scheme used is UTF-8. 13 Apr 2021
  6. 6 endswith() method - str class endswith() method of the str class in Python checks whether a string ends with one of the specified suffixes and return True or False based on the test 10 Mar 2017
  7. 7 expandtabs method of Python str class The expandtabs() method replaces tab stops with spaces. The number of spaces is determined by the cursor position and tab size. The example Python program expands tab stops with spaces in multiple python string variants. 18 Nov 2019
  8. 8 find() method of str class The find() method of python str class finds and returns the lowest index of a specified substring in a given string;Start, Stop positions can be specified. 10 Mar 2017
  9. 9 format() method of str class The format() method dynamically composes a string in Python, through the place holders {} embedded inside a string. The format() also does not require any format specifiers to be provided. 18 Apr 2021
  10. 10 index() method of str class The index() method of str class returns the lowest position of the substring. If the index is not found it raises an exception of type ValueError 10 Mar 2017
  11. 11 isalnum() method of str class isalnum() function of str class will return true if the string has atleast one alphanumeric character. False if it contains one alphanumeric character. 10 Mar 2017
  12. 12 isalpha() method of str class The isalpha() of str class returns True only if a string has all alphabets. Returns False if the string has at least on non-alphabet or if the string is empty. 10 Mar 2017
  13. 13 isascii method of str class in Python The isascii() method returns True, if a string is made of one or more ASCII characters. In other words it returns False, if at least one character in a string is a non-ASCII character. 18 Nov 2019
  14. 14 Method isdecimal() of str class in Python For a string literal, the method isdecimal() returns True if it is composed of all decimal characters. For characters corresponding to simple fractions like 3/4 it returns False. 18 Nov 2019
  15. 15 isdigit() method of str class The isdigit() method tests whether a string objects is composed only of digits. If all the characters are digits it returns True; Returns False otherwise. 11 Mar 2017
  16. 16 isidentifier() method of str class isidentifier() method of str class in checks whether the contents of a string is a valid identifier.Returns true if its is a valid identifier, else returns False. 11 Mar 2017
  17. 17 islower() method of str class The islower() method returns true if all the characters present in a string are lower case letters. Returns false if at least one character is not lower case. 11 Mar 2017
  18. 18 Method isnumeric() of str class in Python The isnumeric() method returns True if all the characters of a string literal are numeric in nature. This may include symbols for simple fractions like ¾ as well.Whereas the method isdecimal() returns False if the literal contains characters corresponding to fractions like U+00BC. 18 Nov 2019
  19. 19 isprintable() method of str class in Python The isprintable() method returns True if all the characters of a string are printable, else it returns False. Examples of non-printable characters include u001C - line feed, u000C - Form feed and others. 19 Nov 2019
  20. 20 join() method of string class join() method of stri class takes multiple strings of an iterable and concatenates them using the source string as sepearator and returns the new string. 12 Mar 2017
  21. 21 ljust() method of str ljust() left justifies a string inside a string of width n.When width is more than the length of original string it is padded with specified characters 12 Mar 2017
  22. 22 lower() method of str class The lower() method of str class in Python returns a copy of the original string where all the characters are lower cased. Example is given with output. 12 Mar 2017
  23. 23 lstrip() method of str class The lstrip method of str class removes leading characters of a string as specified in chars parameter of the method. 13 Mar 2017
  24. 24 partition method of str class The partition() method of python str class splits the string into two parts and it returns the part1, separator, part2 as a tuple of string objects. 13 Mar 2017
  25. 25 removeprefix() Method - Str Class The method removeprefix() of str class in Python, removes a given prefix from a string and returns the modified string. 3 Dec 2020
  26. 26 removesuffix() method - str class The removesuffix() method of str class in Python removes a given suffix and returns the new string. If the suffix is not found the original string is returned. 4 Dec 2020
  27. 27 replace method of str class The replace() method of str class in Python replaces the occurrences of a substring with another substring for a specified number of times. 13 Mar 2017
  28. 28 rfind() method of str class The rfind() method of python str class returns the highest index at which a substring is found;find() is akin to rfind(), but returns the smallest index 13 Mar 2017
  29. 29 rindex method of str class the rindex() method of str class returns the highest index at which a substring is found.rindex() raises exception ValueError if the substring is not found. 13 Mar 2017
  30. 30 rjust() method of str class The method rjust() of str class returns a right justified string within a string of specified width.If fillchar is not specified whitespace is assumed. 13 Mar 2017
  31. 31 rpartition() method of str() class rpartition() splits the string at the highest index where the substring is found and returns a tuple containing the first part, separator and the second part. 13 Mar 2017
  32. 32 rsplit() method of str class The rsplit() method of str class makes multiple tokens out of a string using a delimiter-substring and a count. 13 Mar 2017
  33. 33 rstrip() method of str class rstrip() method of python str class returns new string object with specified leading characters removed. If no characters specified strips white spaces. 14 Mar 2017
  34. 34 split() method of str class split() tokenises a string based on separator and count params.split() starts tokenisation at lowest index of the separator and returns a list of tokens. 14 Mar 2017
  35. 35 splitlines() method of str class The splitlines() tokenises a string with line separators into multiple tokens and returns the tokens as a list 14 Mar 2017
  36. 36 startswith() method of str class The startswith() method of str class checks a string or one of the strings specified in a tuple of strings is a prefix of the string object. 15 Mar 2017
  37. 37 strip() method in Python strip() removes leading and trailing characters of a string as specified in the parameter and returns a copy of the string. 15 Mar 2017
  38. 38 swapcase() method of str class swapcase() converts all the lower case characters of the string object into lower case and all the upper case characters into lower case 15 Mar 2017
  39. 39 title() method of str class title() makes the first letter of every word in a string instance an upper cased letter and returns a copy of the string instance 15 Mar 2017
  40. 40 The upper() method of str class in Python The upper() method converts a Python string of any case (lowercase, mixedcase, titlecase) to uppercase as per the character mapping defined for Unicode. 17 Apr 2021
  41. 41 zfill() method of str class zfill() method of Python str class fills prefixes zeroes on a string of specified width and returns a copy of the string. 15 Mar 2017