美文网首页
python3学习笔记(二)

python3学习笔记(二)

作者: 壹顾倾城 | 来源:发表于2020-04-03 10:11 被阅读0次
【本节知识点】:
      字符串输出
      replace
      格式化 %s   {}  format
      字符串切片

1、四种数据结构


004.jpg
>>> list = ['a', 'b', 1, 2, a, ['x', 'y'], ('z','k')]
>>> print(list)
['a', 'b', 1, 2, 'You are my good friend', ['x', 'y'], ('z', 'k')]
>>> print(list[1])
b
>>> print(list[5])
['x', 'y']
>>> print(list[4])
You are my good friend
>>>

2、列表增加、删除


005.jpg
>>>  list.append("bug")
>>> print(list)
['a', 'b', 1, 2, 'You are my good friend', ['x', 'y'], ('z', 'k'), 'bug']
>>> list.remove(list[-1])
>>> print(list)
['a', 'b', 1, 2, 'You are my good friend', ['x', 'y'], ('z', 'k')]

>>> list = [1,2,3]
>>> list.append(3)
>>> print(list)
[1, 2, 3, 3]
>>> list.append("h")
>>> list.append("e")
>>> print(list)
[1, 2, 3, 'h', 'h', 'e']
>>>
>>> list.remove('e')
>>> print(list)
[1, 2, 3, 'h', 'h']

相关文章

网友评论

      本文标题:python3学习笔记(二)

      本文链接:https://www.haomeiwen.com/subject/piwcphtx.html