本课主题

  • 字符串和操作实战
  • 二进制操作实战
  • List 列表和操作实战
  • Tuple 元組和操作实战
  • Dict 字典和操作实战
  • 作業需求

 

引言

这遍文章简单介绍了 Python 字符串和集合的方法和应用,包括字符串 (String)、列表 (List) 、字典 (Dictionary)、Tuple (元组)

 

字符串和操作实战

以下是字符串类里的函数:

import copy
fruits = ['apple','banana',[7,3,5,2],'straweberry','orange']
copy_fruit = copy.copy(fruits)
deep_fruit = copy.deepcopy(fruits)

# Copy
fruits2 = fruits.copy()
fruits[0] = "APPLE" # 改了做大寫都不會影響原本的列表
fruits[2][1] = 4444444444444444
fruits2[2][2] = "HAHA"

# python 默應只 COPY 第一層
print("fruits List :", fruits)
print("fruits2 List :", fruits2)
print("copy_fruit List :", copy_fruit)
print("deep_fruit List :", deep_fruit)
View Code

相关文章:

  • 2021-07-16
  • 2022-12-23
  • 2022-02-25
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2022-01-24
  • 2021-07-28
猜你喜欢
  • 2021-09-02
  • 2022-02-01
  • 2022-02-04
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
相关资源
相似解决方案