s = "hello,xlj"
>>> import io
>>> sio = io.stringIO(s)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
sio = io.stringIO(s)
AttributeError: module 'io' has no attribute 'stringIO'
>>> sio = io.StringIO(s)
>>> sio
<_io.StringIO object at 0x00000238157C4AF0>
>>> sio.getvalue()
'hello,xlj'
>>> sio.seek(8)
8
>>> sio.write("m")
1
>>> sio.getvalue()
'hello,xlm'
>>> a = 5
>>> 3<a<8
True
>>> a=0b11001
>>> b = 0b0100
>>> a
25
>>> b
4
>>> b = 0b01000
>>> b
8
>>> c = a|b
>>> bin(c)
'0b11001'
>>> bin(a&b)
'0b1000'
>>> bin(a^b)
'0b10001'
>>> a=3
>>> a<<1
6
>>> a<<2
12
>>> a<<3
24
>>> a<<4
48
>>> a=16
>>> a>>1
8
>>> >>2
SyntaxError: invalid syntax
>>> a>>2
4
>>> a>>3
2
>>> a>>4
1
>>> a>>5
0
>>> (5+10*x)/5-13*(y-1)*(a+b)/x+9*(5/x+(12+x)/y)
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
(5+10*x)/5-13*(y-1)*(a+b)/x+9*(5/x+(12+x)/y)
NameError: name 'x' is not defined
>>> a = [20,20,40,"zhangsan"]
>>> a[2]
40
>>> a =a []
SyntaxError: invalid syntax
>>> a = []
>>> a.append(20)
>>> a
[20]
>>> a = list()
>>> a
[]
>>> list("zhangsan")
['z', 'h', 'a', 'n', 'g', 's', 'a', 'n']
>>> range(10)
range(0, 10)
>>> type(range)
<class 'type'>
>>> list(range)
Traceback (most recent call last):
File "<pyshell#45>", line 1, in <module>
list(range)
TypeError: 'type' object is not iterable
>>> list(range(10))
[0, 1, 2, 3,
01-31
23万+
11-11
12-27
03-23
06-13
20万+
09-05
8万+
11-30
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交