第三天作业

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,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值