Discuss / Python / 两个name

两个name

Topic source

std = local_school.student local_school.student = name

t1 = threading.Thread(target= process_thread, args=('Alice',), name='Thread-A')

def process_thread(name):
    # 绑定ThreadLocal的student:
    local_school.student = name
    process_student()

为什么参数name和线程的name不会混淆呢?

threading.Thread(target= process_thread, args=('Alice',))

是这样咩,name是给threading.Thread创建线程的id,给它的参数,可以不指定。args是给process_thread的参数,必须有。


  • 1

Reply