def join(self, iterable): # real signature unknown; restored from __doc__ """ S.join(iterable) -> str Return a string which is the concatenation of the strings in the iterable. The separator between elements is S. """ 上面是库
目录 说明 数据说明 正确示例 错误示例 解决办法 说明 最近在用Python的join函数连接多个列表时,出现了如下两个错误,即合并类型不一致.折腾了很久才找到原因,真是基础不牢,地动山摇. TypeError: sequence item 3: expected str instance, int found 或 TypeError: can only concatenate list (not "str") to list 数据说明 a = ['a','c','c'] b = [
Join的作用是阻塞进程直到线程执行完毕.通用的做法是我们启动一批线程,最后join这些线程结束,例如: for i in range(10): t = ThreadTest(i) thread_arr.append(t) for i in range(10): thread_arr[i].start() for i in range(10): thread_arr[i].join() 此处join的原理就是依次检验线程池中的线程是否结束,没有结束就阻塞直到线程结束,如果结束则跳转执行下一个线程