Monday 26 December 2016

what is raw-string and Unicodel?

Without  r, backslashes are treated as escape characters. With the r, backslashes are treated as literals.
using r means string appears as it is "\| isn't given a special meaning.
Example:
1.a="Story of an Ant\" Grasshopper"
Output: a
          'Story of an Ant" Grasshopper'

2,a=r"Story of an Ant\" Grasshopper"
Output: a
          'Story of an Ant\\" Grasshopper'


Important:
1.r'x', r'''xy''', r"xyz", r"""xyzf""" are all byte string.
2.There is nothing like raw string type .
3.u"xyz" is unicode string where as r"xyz","xyz" are normal byte strings.
4.All require same memory
Example:import sys
>>> sys.getsizeof(u'abcdefgh')
33
>>> sys.getsizeof('abcdefgh')
33
>>> sys.getsizeof(r'abcdefgh')
33