The Road to Python, Part 2: Introduction and Basics of Python 4

Python3  string

              A string is an ordered sequence of characters

              How to represent a string:

                     In non-comments, all parts enclosed in quotation marks are strings;

                     ' single quote ” double quote ''' triple single quote """ triple double quote

                Representation method of empty string:

                   ‘ ’   、  “ ”  、   '''   '''  、   “”“   ”“”

                The boolean value (bool) of an empty string is False.

>>> x = ''
>>> bool(x)
False
>>> x = ' '
>>> bool(x)
True
>>>

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324920984&siteId=291194637