python的集合类型——字符串、列表、元组、字典
发布日期:2021-05-10 19:17:53 浏览次数:20 分类:精选文章

本文共 4206 字,大约阅读时间需要 14 分钟。

������������


���������

������������Python������������������������������������������������������������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

���������������������������������������������������������������������������������������������������������������������������������[������:������:������]���������������������������������������������������������������������������������������������������������������������������������������������������������

������������������"name = 'abcdef'"���������������������������������������������������������������������������������������������������������

# str[���������������������:���������������������:������]
s = 'hello world'
s[:3] # ������: 'hel'
s[3:8] # ������: 'lo w'
s[::2] # ������: 'hlow'

������������������������

  • find()������������������������������������������������������������������������������������������������-1���
  • index()������find()���������������������������������������������������������
  • count()������������������������������������������������������
  • replace()������������������������������������������������
  • split()���������������������������������������������������
  • capitalize()���������������������������������������������������������������
  • title()���������������������������������������
  • startswith() ��� endswith()���������������������������������������������������������������
  • lower() ��� upper()������������������������������������������
  • ljust(), rjust(), center()������������������������
  • lstrip(), rstrip(), strip()������������������������
  • rfind(), rindex()������������find()���index()������������������������������
  • partition(), rpartition()������������������������������������
  • splitlines()������������������������������������������������������������
  • isalpha(), isdigit(), isalnum(), isspace()���������������������������������������������
  • join()������������������������������������������������������

  • ������

    ���������List������������������������������������������������������������������������������������������������������������������������������������len()��������������������������������������������������������������������������������� len(list) - 1���

    ���������������

  • ���������������
    • append()���������������������������������
    • extend()���������������������������������������������
    • insert(index, object)���������������������������������
  • ���������������
    • del������������������������������
    • pop()������������������������������������
    • remove()������������������������������������
  • ���������������
    • in������������������������������
    • not in���������������������������
    • index()���find()���������������������������
  • ���������������
    • sort()���������������������������������reverse���������������������
    • reverse()������������������
  • ���������������������������������������������������������������������������������������������������


    ������

    ���������Tuple������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������


    ������

    ���������Dictionary������������������������������������������������������������������������dictionary���������������������������������������������������

    ������������������

  • ���������������������������������������������������
  • ������������������������������������������������������������������
  • ���������������

  • ���������������{}������������������������������������
  • ������������������������������������get()������������������������
  • ���������������
    • del���������������������
    • pop()������������������������������������������������
    • update()���������������������������
  • ���������������items()������������������������������keys(), values(), items()���������������������������
  • ���������������in������������������������������������������������True���������������������False���
  • ������������������������������������������������������������������������������������������

    ���������������������������������������������������������������������������������������������������������������������������������������������������������������������

    上一篇:数据挖掘
    下一篇:Python的逻辑判断和循环 || 打印九九乘法表

    发表评论

    最新留言

    很好
    [***.229.124.182]2025年04月15日 00时47分08秒