>>> 3>2
True
>>> no True
SyntaxError: invalid syntax
>>> not True
False
>>> 'adc'.encode('ascii')
b'adc'
>>> 中文.encode('ascii')
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
中文.encode('ascii')
NameError: name '中文' is not defined
>>> 中文.encode('utf-8')
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
中文.encode('utf-8')
NameError: name '中文' is not defined
>>> '中文'.encode('utf-8')
b'\xe4\xb8\xad\xe6\x96\x87'
>>> '中文'.encode('ascii')
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
'中文'.encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
>>> len('abcdl')
5
>>> len('中文'.encode('utf-8'))
6
>>> ord('hu')
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
ord('hu')
TypeError: ord() expected a character, but string of length 2 found
KeyboardInterrupt
>>> ord(a)
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
ord(a)
NameError: name 'a' is not defined
>>> ord('u')
117
Traceback (most recent call last):
File "<pyshell#37>", line 1, in <module>
clear
NameError: name 'clear' is not defined
>>> clean
Traceback (most recent call last):
File "<pyshell#38>", line 1, in <module>
clean
NameError: name 'clean' is not defined
>>> 'Age :%s Gender:%s'%(253,xie)
Traceback (most recent call last):
File "<pyshell#39>", line 1, in <module>
'Age :%s Gender:%s'%(253,xie)
NameError: name 'xie' is not defined
>>> a = 'you'
>>> 'Age :%s Gender:%s'%(253,a)
'Age :253 Gender:you'
>>> classmates=['小明','校长','小妹']
>>> classmages
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
classmages
NameError: name 'classmages' is not defined
>>> classmates
['小明', '校长', '小妹']
>>> len(classmates)
3
>>> classmates[0]
'小明'
>>> classmates[3]
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
classmates[3]
IndexError: list index out of range
>>> classmates[3]
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
classmates[3]
IndexError: list index out of range
>>> classmates[-1]
'小妹'
>>> classmates[-3]
'小明'
>>> classmates[-4]
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
classmates[-4]
IndexError: list index out of range
>>> classmates.insert('jack')
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
classmates.insert('jack')
TypeError: insert() takes exactly 2 arguments (1 given)
>>> classmates.insert(3,'jack')
>>> classmates
['小明', '校长', '小妹', 'jack']
>>> classmates.insert(2,'make')
>>> classmates
['小明', '校长', 'make', '小妹', 'jack']
>>> classmates.append('小可')
>>> classmates
['小明', '校长', 'make', '小妹', 'jack', '小可']
>>> classmates.p
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
classmates.p
AttributeError: 'list' object has no attribute 'p'
>>> classmates.pop(4)
SyntaxError: unexpected indent
>>> classmates.pop(4)
'jack'
>>> classmates
['小明', '校长', 'make', '小妹', '小可']
>>> s=[1,3,5,(89,90,78),6,7,8,9]
>>> s
[1, 3, 5, (89, 90, 78), 6, 7, 8, 9]
>>> s[0]=99
>>> s
[99, 3, 5, (89, 90, 78), 6, 7, 8, 9]
>>> s[3][2]='a'
Traceback (most recent call last):
File "<pyshell#25>", line 1, in <module>
s[3][2]='a'
TypeError: 'tuple' object does not support item assignment
>>> s[3][2]
78
>>> t=(1)
>>> t
1
>>> ss=(1,)
>>> ss
(1,)