Basic data types in Day02python-Boolean values and strings

Source: Internet
Author: User
Tags iterable

2. Boolean values

True or False

1 or 0

3. String type

"Hello World"

String Common functions:

-Remove whitespace

-Separate

-Length

-Index

-Slicing

Class Str (basestring): "" "" "" Str (object= "), string Return A nice string representation of the object.    If The argument is a string, the return value is the same object. "" "Def capitalize (self):
"""
a= "Leoday"
temp=a.capitalize ()
Print (temp)
This is directly the output of the Leoday
""""", "" "" "" "" "" "" "" "" S.capitalize (), string Return a copy of the string S with only it fi RST character capitalized. "" "" Return "Def Center (self, Width, fillchar=none):
"""
A=leoday
Temp=a.center (20,****)
Print (temp)
The result of the output is: ******temp******

""""" "Content centered, Width: total length; Fillchar: padding content in white space, default None" "" "" "S.center (width[, Fillchar]), String Retu RN S centered in a string of length width. Padding is do using the specified fill character (default is a space) "" "" Return "" Def count (SE LF, Sub, Start=none, End=none):
"""
This does not understand, what is the number of sub-series
""""", "" "" "" "" "" S.count (sub[, start[, end]), int Return the number of non-overlapping Occurrences of substring sub in string S[start:end]. Optional arguments start and end is interpreted as in slice notation. "" "Return 0 def decode (self, Encoding=none, Errors=none):
"""
This does not understand, what is the decoding of the two parameters how to write
""""" "Decode" "" "" "S.decode ([Encoding[,errors]), object decodes S using the codec Registere D for encoding. Encoding defaults to the default encoding. Errors May is given to set a different error handling scheme. Default is ' strict ' meaning that encoding errors raise a unicodedecodeerror. Other possible values is ' ignore ' and ' replace ' as well as a-name registered with Codecs.register_error th At are able to handle unicodedecodeerrors. "" "Return Object () def encode (self, Encoding=none, Errors=none):
"""
This does not understand, the code after the two parameters of the specific wording
""" "" "Encoding, for Unicode" "" "" "S.encode ([Encoding[,errors]), object encodes S using t He codec registered for encoding. Encoding defaults to the default encoding. Errors May is given to set a different error handling scheme. Default is ' strict ' meaning that encoding errors raise a unicodeencodeerror. Other possible values is ' ignore ', ' replace ' and ' xmlcharrefreplace ' as well as ' all other ' name registered with Codecs.register_error that's able to handle unicodeencodeerrors. "" "Return Object () def endswith (self, suffix, start=none, end=none):" "" whether End with XXX "" "" " S.endswith (suffix[, start[, end]), bool Return True if S ends with the specified suffix, False ot Herwise. With optional start, test S beginning on that position. With optional end, stop comparing S on that position. Suffix can also is a tuple of strings to try. """ Return False def expandtabs (self, Tabsize=none): "" "converts tab to space, default one tab to 8 spaces" "" "" S.ex Pandtabs ([Tabsize]), string Return a copy of S where all tab characters is expanded using spaces. If Tabsize is not given, the a tab size of 8 characters is assumed. "" "" "Return" "Def find (self, sub, Start=none, End=none):" "To find the sub-sequence position, if not found, return-1" "" "" S.find (Sub [, Start [, end]]), int Return the lowest index in S where substring sub is found, suc H. Sub is contained within S[start:end]. Optional arguments start and end is interpreted as in slice notation. Return-1 on failure. "" "Return 0 def format (*args, **kwargs): # Known special case of Str.format" "" string format, dynamic parameter, will function programming in detail "" "" "" "S.format (*args, **kwargs), string Return A formatted version of S, using Substitut Ions from args and Kwargs. The substitutions is identified by braces (' {' and '} '). "" "Pass Def Index (self, sub, Start=none, End=none):" "" sub-sequence position, if not found, error "" "S.index (sub [, Start [, end]]) , int like S.find () but raise valueerror when the substring was not found. "" "Return 0 def isalnum (self):" "" is the letter and number "" "" "" S.isalnum (), BOOL Return True If all characters in S is alphanumeric and there was at least one character in S, False otherwise. "" "Return False def isalpha (self):" "" is the letter "" "" "" S.isalpha (), BOOL Return True If all characters in S was alphabetic and there is at least one character in S, False Otherwis E. "" "Return False def isdigit (self):" "" is the Number "" "" "" S.isdigit (), BOOL Return True If all characters in S was digits and there is at LEAsT one character in S, False otherwise. "" "Return False def islower (self):" "" Whether lowercase "" "" "" S.islower (), BOOL Return True If all cased characters in s was lowercase and there is at least one cased character in S, False othe Rwise. "" "Return False def isspace (self):" "" "" "" S.isspace () bool return True if all Characters in S was whitespace and there is at least one character in S, False otherwise. "" "Return False def istitle (self):" "" "" "" S.istitle () bool return True if S i s a titlecased string and there are at least one character in S, i.e. uppercase characters could only follow uncased Characters and lowercase characters only cased ones. Return False otherwise. "" "Return False def isupper (self):" "" "" "" S.isupper () bool return True if all Cased Characters in S was uppercase and there is at least one cased character in S, False otherwise. "" "Return False def join (self, iterable):" "" "" "" "" "" "" "" S.join (iterable) string Return a string which is the concatenation of the strings in the iterable. The separator between elements is S. "Return" "Def ljust (self, Width, fillchar=none):" "Content left-aligned, right padding" "" "" S.ljust (width [, Fillchar]) String Return S left-justified in a string of length width. Padding is do using the specified fill character (default is a space). RN a copy of the string S converted to lowercase. "" "" "Return" "Def Lstrip (Self, Chars=none):" "" Remove left blank "" "" "" S.lstrip ([chars]), St Ring or Unicode Return a copy of the string S with leading whitespace removed. If chars is given and isn't None, remove characters in chars instead. If chars is Unicode, S'll be converted to Unicode before stripping "" "Return" Def partition (self, SE p): "" "split, before, in, and after three parts" "" "" "S.partition (Sep)--(head, Sep, tail) Search for the Separator Sep in S, and return the part before it, the separator itself, and the. If The separator is not found, return S and both empty strings. "" "Pass def replace (self, old, new, Count=none):" "Replace" "" "" "S.replace (old, new[, cou NT]), string Return a copy of string S with all occurrences of substring-replaced by new. If The optional argument count is given, only the first count occurrences is replaced. "" "" Return "" Def RFind (self, sub, Start=none, End=none): "" "S.rfind (sub [, Start [, end]]), int Return the highest index in S where substring sub is fo und, such that sub is contained within S[start:end]. Optional arguments start and end is interpreted as in slice notation. Return-1 on failure. "" "Return 0 def rindex (self, sub, Start=none, End=none):" "" S.rindex (sub [, Start [, end]])-&gt ; int like S.rfind () but raise valueerror when the substring was not found. "" "Return 0 def rjust (self, Width, fillchar=none):" "" S.rjust (width[, Fillchar]), string Return S right-justified in a string of length width. Padding is do using the specified fill character (default is a space) "" "Return" "Def Rpartiti On (self, Sep): "" "S.rpartition (Sep)--(head, Sep, tail) Search for the separator Sep i n S, starting at the end of S, and return The part before it, the separator itself, and the. If The separator is not found, return both empty strings and S. "" "Pass Def rsplit (self, Sep=none, Maxsplit=none):" "" S.rsplit ([Sep [, Maxsplit]]) List o F Strings Return A list of the words in the string S, using Sep as the delimiter string, starting at The end of the string and working to the front. If Maxsplit is given, at most maxsplit splits be done. If Sep is no specified or is None, any whitespace string is a separator. "" "Return [] def rstrip (self, Chars=none):" "" S.rstrip ([chars])-string or Unicode Return a copy of the string S with trailing whitespace removed. If chars is given and isn't None, remove characters in chars instead. If chars is Unicode, S'll be converted to Unicode before stripping "" "" Return "Def split (self, sep=None, Maxsplit=none): "" "split, maxsplit up to several times" "" "" "S.split ([Sep [, Maxsplit]), List of Strin GS Return A list of the words in the string S, using Sep as the delimiter string. If Maxsplit is given, at most maxsplit splits be done. If Sep is no specified or is None, any whitespace string is a separator and empty strings be removed from The result. "" "Return [] def splitlines (self, Keepends=false):" "" "" "" "" "" "" "S.splitlines (Keepe Nds=false), List of strings Return a list of the lines in S, breaking on line boundaries. Line breaks be included in the resulting list unless keepends is given and true. "" "Return [] def startswith (self, prefix, Start=none, end=none):" "" whether Start "" "" "" S.star Tswith (prefix[, start[, end]), bool Return True if S starts with the specified prefix,False otherwise. With optional start, test S beginning on that position. With optional end, stop comparing S on that position. Prefix can also is a tuple of strings to try. "" "Return False def strip (self, Chars=none):" "" Remove two paragraphs of blank "" "" "" S.strip ([chars])-S Tring or Unicode Return a copy of the string S with leading and trailing whitespace removed. If chars is given and isn't None, remove characters in chars instead. If chars is Unicode, S'll be converted to Unicode before stripping "" "Return" Def Swapcase (self): "" "uppercase lowercase, lowercase to uppercase" "" "" "" S.swapcase () string Return a copy of the string S with U Ppercase characters converted to lowercase and vice versa. "" "Return" "def title (self):" "" "" S.title ()-String return a titlecased ver Sion of S, i.e. words start with Uppercase characters, all remaining cased characters has lowercase. "" "" "Return" "Def translate (self, table, Deletechars=none):" "" "" conversion, you need to first make a corresponding table, the last one represents the deletion of the character set Intab = "Aeiou" Outtab = "12345" Trantab = Maketrans (intab, outtab) str = "This is string example. .. WOW!!! " Print str.translate (Trantab, ' XM ') "" "" "" S.translate (table [, Deletechars]), string Return a copy of the string S, where all characters occurring in the optional argument deletechars is removed, And the remaining characters has been mapped through the given translation table, which must be a string o F Length or None. If The table argument is None, no translation are applied and the operation simply removes the characters in Deletec HARs. "" "" "Return" "Def Upper (self):" "" "" S.upper () string return a copy of the St Ring S ConverTed to uppercase. "" "Return" "Def zfill (Self, width):" "method returns a string of the specified length, the original string is right-aligned, and the front padding is 0. "" "" "" "S.zfill (width), string Pad A numeric string S with zeros on the left, to fill a field of the specified width. The string S is never truncated. "" "" Return "" Def _formatter_field_name_split (self, *args, **kwargs): # Real Signature Unknown pass de F _formatter_parser (self, *args, **kwargs): # Real Signature Unknown pass def __add__ (self, y): "" "X._ _add__ (y) <==> x+y "" "Pass Def __contains__ (self, y):" "" x.__contains__ (y) <==> y in X "" "Pass Def __eq__ (self, y):" "" "" x.__eq__ (y) <==> x==y "" "Pass def __format__ MAT_SPEC): "" "s.__format__ (Format_spec), string Return A formatted version of S as De Scribed by Format_spec. "" "Return" "Def __getattribute__ (SELF, name): "" "x.__getattribute__ (' name ') <==> x.name" "" Pass Def __getitem__ (self, y): "" "x.__getitem__ (y) <==> x[y]" "" Pass Def __getnewargs__ (self, *args, **kwargs): # Real Signature Unkno WN Pass def __getslice__ (self, I, j): "" "X.__getslice__ (i, J) <==> X[i:j] Use of negative indices are not supported. "" "Pass Def __ge__ (self, y):" "" "x.__ge__ (y) <==> x>=y" "" Pass Def __gt__ (self, y) : "" "x.__gt__ (y) <==> x>y" "" Pass Def __hash__ (self): "" "x.__hash__ () <==> H Ash (x) "" "Pass Def __init__ (self, string="): # Known special case of str.__init__ "" "Str (object = ") string Return A nice string representation of the object. If The argument is a string, the return value is the same object. # (copied from class Doc)"" "Pass Def __len__ (self):" "" "" x.__len__ () <==> len (x) "" "Pass Def __le__ (self, y): "" "x.__le__ (y) <==> x<=y" "" Pass Def __lt__ (self, y): "" "x.__lt__ (y) <==> X&L T;y "" "Pass Def __mod__ (self, y):" "" "" x.__mod__ (y) <==> x%y "" "Pass Def __mul__ (self, N): "" "X.__mul__ (n) <==> x*n" "" Pass @staticmethod # known case of __new__ def __new__ (S, * More): "" "t.__new__ (S, ...) A new object with type S, a subtype of T "" "Pass Def __ne__ (self, y):" "" x.__ne__ (y) <==> X!=y "" "Pass Def __repr__ (self):" "" "" x.__repr__ () <==> repr (x) "" "Pass Def __rmod__ ( Self, y): "" "x.__rmod__ (y) <==> y%x" "" Pass Def __rmul__ (self, N): "" "" X.__rmul__ (N) & lt;==> n*x "" "Pass Def __sizeof__ (self):" "" s.__sizeof__ (), size of S in memory, in bytes "" "Pass Def __str__ (self):" "" "" x.__str__ () <==> str (x) "" "Pass

  

Basic data types in Day02python-Boolean values and strings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.