Programming/Python
copy - shallow, deep : 깊은복사, 얕은복사
Chan_찬
2020. 8. 19. 10:03
반응형
list
>>> num_list = [1,2,3,4]
# deep copy
>>> new_list = num_list[:]
>>> new_list2 = list(num_list)
set
>>> str_set = {'Jane', 'Tim', 'John'}
# deep copy
>>> new_set = str_set.copy()
dict
>>> str_dict = {'hi': 'world'}
# deep copy
>>> new_dict = str_dict.copy()
use copy
module
>>> import copy
>>> object = 'other something object'
>>> new_obj = copy.copy(object) # shallow copy
>>> new_obj2 = copy.deepcopy(object) # deep copy
728x90
반응형
BIG