Python Notes

String / String Literals  [' ' or " " but no mix, have to be consistent]
=============================================================
    - strings in Python have data type 'str'
    - str is Unicode (Python 3  source endcoding UTF-8)
    - date type of strings (in Python)  
    - sequence of Unicode code points (like characther but exactly not that)
    - immutable (cant change/modify it's content)
    - string constructor: str() [used to represent string from other type]
Strings with Newlines:
========================
[1] multiline strings
    - spread the literal across multiple lines
    - use: """   """ or '''  ''' [covered by 3 single / double quotes] =>  '... \n ...'
    [Universal Newlines]
    - Python translates \n - to appropriate newline sequence for your platform (windows/mac/linux)
[2] escape sequences (embaded escapse sequences in a ling-line literal)
    - 'a \' in a string'        # 'a ' in a string'
    - 'a \\ in a string'        # 'a \ in a string'
 
 
 path = r'C:\a.txt' # 'C:\\a.txt'   [raw string ]
 str(123)           # '123'         [constructor]
 s = 'few steps'
 s[2]               # 'e'           [sequence types]
 type(s[2])         # 
 help(str)                          [string has lots of methods]
 s.capitalize()     # Few Steps




image source: https://perso.limsi.fr

Popular posts from this blog

GOOGLEFINANCE attributes

Practice

Merge/join two or more video files using Python