当前位置:网站首页>Example 007: copy data from one list to another list.
Example 007: copy data from one list to another list.
2022-07-05 08:22:00 【Lazy smile】
example 007:copy
subject : Copy data from one list to another .
Program analysis :
We can use the following methods to copy : Direct assignment =、 Indexes [:]、copy()、deepcopy()
The code is as follows :
import copy
a = [1, 2, 3, 4, ['a', 'b']]
b = a # assignment
c = a[:] # Shallow copy
d = copy.copy(a) # Shallow copy
e = copy.deepcopy(a) # Deep copy
a.append(5)
a[4].append('c')
print('a=', a)
print('b=', b)
print('c=', c)
print('d=', d)
print('e=', e)a= [1, 2, 3, 4, ['a', 'b', 'c'], 5]
b= [1, 2, 3, 4, ['a', 'b', 'c'], 5]
c= [1, 2, 3, 4, ['a', 'b', 'c']]
d= [1, 2, 3, 4, ['a', 'b', 'c']]
e= [1, 2, 3, 4, ['a', 'b']]
summary :
"""
Deep copy , Depth of copy : I have opened up a new memory , Copy all the copied contents
Deep copy of the list is to change the new list no matter how ( Unidimensional or Multidimensional ), The original list remains unchanged .
Shallow copy , The degree of copying is shallow , Only the first address of the original data is copied , Then through the first address of the original data , To get content .
Shallow copy , For multidimensional lists , Only the first dimension deep copy
"""
边栏推荐
- WiFi wpa_ Detailed description of supplicant hostpad interface
- Explain task scheduling based on Cortex-M3 in detail (Part 1)
- Carrier period, electrical speed, carrier period variation
- Vofa+ software usage record
- 關於線性穩壓器的五個設計細節
- The firmware of the connected j-link does not support the following memory access
- Detailed explanation of SQL server stored procedures
- Synchronization of QT multithreading
- [trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
- Halcon's practice based on shape template matching [1]
猜你喜欢

Sword finger offer 06 Print linked list from end to end

Let's briefly talk about the chips commonly used in mobile phones - OVP chips
AttentiveNAS: Improving Neural Architecture Search via Attentive Sampling (未完)](/img/3b/c94b8466370f4461875c85b4f66860.png)
[NAS1](2021CVPR)AttentiveNAS: Improving Neural Architecture Search via Attentive Sampling (未完)

Explain task scheduling based on Cortex-M3 in detail (Part 1)

STM32 --- NVIC interrupt

Stm32--- systick timer

Briefly talk about the identification protocol of mobile port -bc1.2

【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)

实例003:完全平方数 一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?

Management and use of DokuWiki
随机推荐
Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
MySQL之MHA高可用集群
剑指 Offer 09. 用两个栈实现队列
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
What are the test items of power battery ul2580
Stablq of linked list
Talk about the function of magnetic beads in circuits
Several implementation schemes of anti reverse connection protection of positive and negative poles of power supply!
Ble encryption details
实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
Bootloader implementation of PIC MCU
[tutorial 19 of trio basic from introduction to proficiency] detailed introduction of trio as a slave station connecting to the third-party bus (anybus PROFIBUS DP...)
After installing the new version of keil5 or upgrading the JLINK firmware, you will always be prompted about the firmware update
C WinForm [help interface - send email] - practice five
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
Live555 RTSP audio and video streaming summary (II) modify RTSP server streaming URL address
Compilation warning solution sorting in Quartus II
Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
Semiconductor devices (III) FET
Adaptive filter