目录
- 浅拷贝(copy)和深拷贝(deepcopy)
 - 编写一个生成器,将一个二维列表转换为一维列表
 - 请编写一个递归生成器,将任意多维的列表转换为一维列表
 - 如何分别获取当前日期的年月日以及在一年中的第几天
 - 进程之间的通信
 - 如何为一个线程函数传递参数
 - 在线程中如何创建和使用全局对象
 - 你了解协程吗
 
0.1浅拷贝(copy)和深拷贝(deepcopy)

'''
copy:只复制深层对象的引用
deepcopy:复制深层对象的本身
'''
import copy
a = [1, 2, 3, 4, ['a', 'b']]
c = copy.copy(a)    # 浅拷贝
d = copy.deepcopy(a)    # 深拷贝
a.append(5) # 在顶层,无论浅还是深,顶层都完全复制
print(c)	# [1, 2, 3, 4, ['a', 'b']]
print(d)	# [1, 2, 3, 4, ['a', 'b']]
a[4][0] = 'x'
print(a)	# [1, 2, 3, 4, ['x', 'b'], 5]
print(d)	# [1, 2, 3, 4, ['a', 'b']]
总结
0.2编写一个生成器,将一个二维列表转换为一维列表

'''
生成器:yield
'''
def myGenerator():
    numlist = [1, 2, 3, 4 , 5, 6, 7]
    for num in numlist:
        yield num
for num in myGenerator():
    print(num, end=' ')	# 1 2 3 4 5 6 7 
[[1, 2, 3], [2, 3, 4]] ---> [1. 2. 3. 2. 3. 4]
def enumList(nestedList):
    for subList in nestedList:
        for element in subList:
            yield element
nestedList = [[1, 2, 3], [2, 3, 4]]
for num in enumList(nestedList):
    print(num, end=' ')	
1 2 3 2 3 4 
总结
0.3请编写一个递归生成器,将任意多维的列表转换为一维列表

def enumList(nestedList):
    try:
        for subList in nestedList:
            for element in enumList(subList):
                yield element
    except TypeError:
        yield nestedList    # 迭代单个值
nestedList = [4, [1, 2, 3], [2, 3, 4, [1, [2, 5], [2, 3], 5], 6]]
for num in enumList(nestedList):
    print(num, end=' ')
4 1 2 3 2 3 4 1 2 5 2 3 5 6    
总结
0.4如何分别获取当前日期的年月日以及在一年中的第几天

import time
localtime = time.localtime(time.time())
print(localtime.tm_year)	# 2020
print(localtime.tm_mon)		# 2
print(localtime.tm_mday)	# 29(这个月第29天)
print(localtime.tm_hour)	# 21
print(localtime.tm_yday)	# 60(今年第60天)
总结
0.5进程之间的通信



.join()等待,不写.join()会立即执行下面的
0.6如何为一个线程函数传递参数


总结
0.7在线程中如何创建和使用全局对象

这个全局变量只针对当前线程,不能在多个线程之间共享
总结
0.8你了解协程吗

题一
题二
1.run
2.create_task
总结
来源:CSDN
作者:Glen_Zou
链接:https://blog.csdn.net/qq_36551226/article/details/104581048