Printing a list using python

前端 未结 4 463
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 21:27

I have a list compiled from excel cells, using python - say listlist. Each element in the cell/list is in unicode. When I print the list as

pri         


        
4条回答
  •  余生分开走
    2020-12-11 22:06

    when you are printing a list, python prints a representation of the list.

    the default representation of a list is to print an opening square brackets ([), then the representation of each element separated by a comma (,), the a closing square bracket (]). (to be precise the representation of an object is what is returned when calling its __repr__() member). note that the default representation of a unicode string is u'...'.

    now, when you are printing a string, you are not printing the representation of the string, you are printing the string (the value returned by calling the __str__() member). and the string does not include formatting charaters like unicode flags, quotes, etc...

提交回复
热议问题