Python basics
Comments
Types
- numeric (int, float, long, complex)
- iterator
- sequence (str, unicode, list, tuple, buffer, xrange)
- set
- map
- file
Numbers
integer=7
, long=9999999999L
, float=1.34
, complex=0+1j
Strings
'single quotes'
, "double quotes"
, r'raw\n'
, u'unicode\u0020'
, 'multi\
line (end of lines must be escaped)'
, '''strings in triple quotes can span
multiple
lines without escaping newlines'''
- can be concatenated (
'dirty ' + 'monkey'
) and repeated (4 * 'lol'
)
- literals next to each other are automatically concatenated (
'you' 'tube'
)
- can be sliced (
word[4]
, word[0:6]
, word[1:]
, word[0:-1]
)
- cannot be changed (unmutable)
- (
)
No comments:
Post a Comment