>>> 'bbb'; "fffff";
'bbb'
'fffff'
>>> """this is a
lines of lines of
comments"""
'this is a\nlines of lines of\ncomments'
>>> 'u\34ee', '\x3e', '\oxx'
('u\x1cee', '>', '\\oxx')
>>> '\033','\o33'
('\x1b', '\\o33')
>>> 'u\23ee','\x3e','\032'
('u\x13ee', '>', '\x1a')
>>> u'\xf8', u'nci\u00f8de'
(u'\xf8', u'nci\xf8de')
>>> r"c:\path\to\files";
'c:\\path\\to\\files'
>>> str(3.14),str(44)
('3.14', '44')
>>> s = 'a line of seq'
>>> s.decode('utf-8'), s.encode('utf-8')
(u'a line of seq', 'a line of seq')
>>> chr(33), unichr(345)
('!', u'\u0159')
>>> s.find('li');s.rfind('li',2);s.index('li')
2
2
2
>>> s.count('e');s.endswith('er');s.startswith('a ')
2
False
True
>>> s.capitalize();s.lower();s.upper();s.swapcase();s.title()
'A line of seq'
'a line of seq'
'A LINE OF SEQ'
'A LINE OF SEQ'
'A Line Of Seq'
>>> s.partition('e');s.rpartition('n');s.split('e');s.rsplit(' ')
('a lin', 'e', ' of seq')
('a li', 'n', 'e of seq')
['a lin', ' of s', 'q']
['a', 'line', 'of', 'seq']
>>> import string
>>> string.hexdigits; string.digits;string.letters;string.lowercase;string.octdigits
'0123456789abcdefABCDEF'
'0123456789'
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xaa\xb5\xba\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
'abcdefghijklmnopqrstuvwxyz\x83\x9a\x9c\x9e\xaa\xb5\xba\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
'01234567'
>>> for x in range(1,11):
print repr(x).rjust(2), repr(x*x).rjust(3),
print repr(x**3).rjust(4)
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000
>>> s.isalnum(), s.isalpha()
(False, False)
>>> s.isdigit(), s.islower(), s.isspace(), s.istitle(), s.isupper()
(False, True, False, False, False)
'bbb'
'fffff'
>>> """this is a
lines of lines of
comments"""
'this is a\nlines of lines of\ncomments'
>>> 'u\34ee', '\x3e', '\oxx'
('u\x1cee', '>', '\\oxx')
>>> '\033','\o33'
('\x1b', '\\o33')
>>> 'u\23ee','\x3e','\032'
('u\x13ee', '>', '\x1a')
>>> u'\xf8', u'nci\u00f8de'
(u'\xf8', u'nci\xf8de')
>>> r"c:\path\to\files";
'c:\\path\\to\\files'
>>> str(3.14),str(44)
('3.14', '44')
>>> s = 'a line of seq'
>>> s.decode('utf-8'), s.encode('utf-8')
(u'a line of seq', 'a line of seq')
>>> chr(33), unichr(345)
('!', u'\u0159')
>>> s.find('li');s.rfind('li',2);s.index('li')
2
2
2
>>> s.count('e');s.endswith('er');s.startswith('a ')
2
False
True
>>> s.capitalize();s.lower();s.upper();s.swapcase();s.title()
'A line of seq'
'a line of seq'
'A LINE OF SEQ'
'A LINE OF SEQ'
'A Line Of Seq'
>>> s.partition('e');s.rpartition('n');s.split('e');s.rsplit(' ')
('a lin', 'e', ' of seq')
('a li', 'n', 'e of seq')
['a lin', ' of s', 'q']
['a', 'line', 'of', 'seq']
>>> import string
>>> string.hexdigits; string.digits;string.letters;string.lowercase;string.octdigits
'0123456789abcdefABCDEF'
'0123456789'
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xaa\xb5\xba\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
'abcdefghijklmnopqrstuvwxyz\x83\x9a\x9c\x9e\xaa\xb5\xba\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
'01234567'
>>> for x in range(1,11):
print repr(x).rjust(2), repr(x*x).rjust(3),
print repr(x**3).rjust(4)
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000
>>> s.isalnum(), s.isalpha()
(False, False)
>>> s.isdigit(), s.islower(), s.isspace(), s.istitle(), s.isupper()
(False, True, False, False, False)
Comments
Post a Comment