python深浅拷贝

python深浅拷贝Python 中 对象的赋值 拷贝 深 浅拷贝 之间是有差异的 如果使用的时候不注意 就可能产生意外的结果 下面本文就通过简单的例子介绍一下这些概念之间的差别 要想了解深浅拷贝 首先要知道什么是深浅拷贝 深拷贝是对于一个对象所有层次的拷贝 递归 copy deepcopy nbsp nbsp nbsp 浅拷贝是对于一个对象的顶层拷贝 通俗的理解是 拷贝了引用 并没有拷贝内容 copy cop

Python中,对象的赋值,拷贝(深/浅拷贝)之间是有差异的,如果使用的时候不注意,就可能产生意外的结果。

下面本文就通过简单的例子介绍一下这些概念之间的差别。

  • 要想了解深浅拷贝,首先要知道什么是深浅拷贝?
  • 深拷贝是对于一个对象所有层次的拷贝(递归)copy.deepcopy
        浅拷贝是对于一个对象的顶层拷贝;通俗的理解是:拷贝了引用,并没有拷贝内容.copy.copy

    #    要想知道两者的区别,首先要知道什么是可变类型和不可变类型?
        
        不可变类型:整型,长整型,浮点数,复数,布尔,字符串,元组
        可变类型:列表,字典。

    #    深浅拷贝有什么区别那?
        
        1、如果用copy.copy、copy.deepcopy对一个全部都是不可变类型的数据进行拷贝,那么它们结果相同,都是引用指向;

        2、如果拷贝的是一个拥有不可变类型的数据,即使元组是最顶层,那么deepcopy依然是深拷贝,而copy.copy还是指向











  •   在python中的数据类型包括:bool、int、long、float、str、set、list、tuple、dict等等。我们可以大致将这些数据类型归类为简单数据类型和复杂的数据结构。

    预备知识——各基本数据类型的地址存储及改变情况

  • 我的划分标准是,如果一个数据类型,可以将其他的数据类型作为自己的元素,我就认为这是一种数据结构。数据结构的分类有很多种,但是在Python中常用的只有集合、序列和映射三种结构。对应python中的set、list(tuple、str)、dict;常用的数据类型有int、long、float、bool、str等类型。(其中,str类型比较特别,因为从C语言的角度来说,str其实是一个char的集合,但是这与本文的关联不大,所以我们暂时不谈这个问题)
  •   python深浅拷贝

      由于python中的变量都是采用的引用语义,数据结构可以包含基础数据类型,导致了在python中数据的存储是下图这种情况,每个变量中都存储了这个变量的地址,而不是值本身;对于复杂的数据结构来说,里面的存储的也只只是每个元素的地址而已。:

      python深浅拷贝

      1.数据类型重新初始化对python语义引用的影响

      变量的每一次初始化,都开辟了一个新的空间,将新内容的地址赋值给变量。对于下图来说,我们重复的给str1赋值,其实在内存中的变化如下右图:

      python深浅拷贝         python深浅拷贝

      从上图我们可以看出,str1在重复的初始化过程中,是因为str1中存储的元素地址由’hello world’的地址变成了’new hello world’的。

      2.数据结构内部元素变化重对python语义引用的影响

      对于复杂的数据类型来说,改变其内部的值对于变量的影响:

      python深浅拷贝         python深浅拷贝

      当对列表中的元素进行一些增删改的操作的时候,是不会影响到lst1列表本身对于整个列表地址的,只会改变其内部元素的地址引用。可是当我们对于一个列表重新初始化(赋值)的时候,就给lst1这个变量重新赋予了一个地址,覆盖了原本列表的地址,这个时候,lst1列表的内存id就发生了改变。上面这个道理用在所有复杂的数据类型中都是一样的

  •   搞明白了上面的内容,再来探讨变量的赋值,就变得非常简单了。

    变量的赋值

  •   1.str的赋值
    print("变量的赋值") str1 = "hello world" print(str1) print(id(str1)) #  str2 = str1 print(id(str2)) #  str1 = "new world" print(str1) print(str2) print(id(str1)) #  print(id(str2)) # 

      python深浅拷贝           python深浅拷贝

      我们刚刚已经知道,str1的再次初始化(赋值)会导致内存地址的改变,从上图的结果我们可以看出修改了str1之后,被赋值的str2从内存地址到值都没有受到影响。

      看内存中的变化,起始的赋值操作让str1和str2变量都存储了‘hello world’所在的地址,重新对str1初始化,使str1中存储的地址发生了改变,指向了新建的值,此时str2变量存储的内存地址并未改变,所以不受影响。

    2.复杂的数据结构中的赋值

      刚刚我们看了简单数据类型的赋值,现在来看复杂数据结构变化对应内存的影响。

  •   python深浅拷贝         python深浅拷贝
    print("复杂的数据结构中的赋值") list1 = [1, 2, 3, 4, 5, 6] list2 = list1 print(id(list1)) #  print(id(list2)) #  list1.append('new item') print(list1) # [1, 2, 3, 4, 5, 6, 'new item'] print(list2) # [1, 2, 3, 4, 5, 6, 'new item'] print(id(list1)) #  print(id(list2)) # 

      上图对列表的增加修改操作,没有改变列表的内存地址,lst1和lst2都发生了变化。

      对照内存图我们不难看出,在列表中添加新值时,列表中又多存储了一个新元素的地址,而列表本身的地址没有变化,所以lst1和lst2的id均没有改变并且都被添加了一个新的元素。

      简单的比喻一下,我们出去吃饭,lst1和lst2就像是同桌吃饭的两个人,两个人公用一张桌子,只要桌子不变,桌子上的菜发生了变化两个人是共同感受的。

    初识拷贝

      我们已经详细了解了变量赋值的过程。对于复杂的数据结构来说,赋值就等于完全共享了资源,一个值的改变会完全被另一个值共享。

      然而有的时候,我们偏偏需要将一份数据的原始内容保留一份,再去处理数据,这个时候使用赋值就不够明智了。python为这种需求提供了copy模块。提供了两种主要的copy方法,一种是普通的copy,另一种是deepcopy。我们称前者是浅拷贝,后者为深拷贝。

      深浅拷贝一直是所有编程语言的重要知识点,下面我们就从内存的角度来分析一下两者的区别。

    浅拷贝

      首先,我们来了解一下浅拷贝。浅拷贝:不管多么复杂的数据结构,浅拷贝都只会copy一层。下面就让我们看一张图,来了解一下浅浅拷贝的概念。

    python深浅拷贝   python深浅拷贝

          看上面两张图,我们加入左图表示的是一个列表sourcelist,sourcelist = [‘str1′,’str2′,’str3′,’str4′,’str5’,[‘str1′,’str2′,’str3′,’str4′,’str5’]];

      右图在原有的基础上多出了一个浅拷贝的copylist,copylist = [‘str1′,’str2′,’str3′,’str4′,’str5’,[‘str1′,’str2′,’str3′,’str4′,’str5’]];

      sourcelist和copylist表面上看起来一模一样,但是实际上在内存中已经生成了一个新列表,copy了sourceLst,获得了一个新列表,存储了5个字符串和一个列表所在内存的地址。

          我们看下面分别对两个列表进行的操作,红色的框框里面是变量初始化,初始化了上面的两个列表;我们可以分别对这两个列表进行操作,例如插入一个值,我们会发现什么呢?如下所示:

             python深浅拷贝

       从上面的代码我们可以看出,对于sourceLst和copyLst列表添加一个元素,这两个列表好像是独立的一样都分别发生了变化,但是当我修改lst的时候,这两个列表都发生了变化,这是为什么呢?我们就来看一张内存中的变化图:

             python深浅拷贝

      我们可以知道sourceLst和copyLst列表中都存储了一坨地址,当我们修改了sourceLst1的元素时,相当于用’sourceChange’的地址替换了原来’str1’的地址,所以sourceLst的第一个元素发生了变化。而copyLst还是存储了str1的地址,所以copyLst不会发生改变。

      当sourceLst列表发生变化,copyLst中存储的lst内存地址没有改变,所以当lst发生改变的时候,sourceLst和copyLst两个列表就都发生了改变。

      这种情况发生在字典套字典、列表套字典、字典套列表,列表套列表,以及各种复杂数据结构的嵌套中,所以当我们的数据类型很复杂的时候,用copy去进行浅拷贝就要非常小心。。。

  • print("浅拷贝") import copy lst = ['str1', 'str2', 'str3'] sourcelst = ['str1', 'str2', 'str3', lst] copylst = copy.copy(sourcelst) print("原本地址") print([id(ele) for ele in sourcelst]) print([id(ele) for ele in copylst]) print("当sourceLst列表发生变化,copyLst中存储的lst内存地址没有改变") sourcelst.append('source') copylst.append('copy') print("->sourcelst: ", sourcelst) print("->copylst: ", copylst) print(id(sourcelst)) # 4 print(sourcelst) # 5 print([id(ele) for ele in sourcelst]) print(id(copylst)) # 4 print(copylst) # 5 print([id(ele) for ele in copylst]) print("sourceLst的第一个元素发生了变化。而copyLst还是存储了str1的地址,所以copyLst不会发生改变。") print([id(ele) for ele in sourcelst]) print([id(ele) for ele in copylst]) sourcelst[0] = 'change' print("->sourcelst: ", sourcelst) print("->copylst: ", copylst) print(id(sourcelst)) # 4 print(sourcelst) # 5 print([id(ele) for ele in sourcelst]) print(id(copylst)) # 4 print(copylst) # 5 print([id(ele) for ele in copylst]) print("以当lst发生改变的时候,sourceLst和copyLst两个列表就都发生了改变。") print([id(ele) for ele in sourcelst]) print([id(ele) for ele in copylst]) lst.append('Append') print("->sourcelst: ", sourcelst) print("->copylst: ", copylst) print(id(sourcelst)) # 4 print(sourcelst) # 5 print([id(ele) for ele in sourcelst]) print(id(copylst)) # 4 print(copylst) # 5 print([id(ele) for ele in copylst]) #3 C:\Anaconda3\python.exe H:/python/venv/pizza.py 浅拷贝 原本地址 [, , , ] [, , , ] 当sourceLst列表发生变化,copyLst中存储的lst内存地址没有改变 ->sourcelst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] ->copylst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'copy']  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] [, , , , ]  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'copy'] [, , , , ] sourceLst的第一个元素发生了变化。而copyLst还是存储了str1的地址,所以copyLst不会发生改变。 [, , , , ] [, , , , ] ->sourcelst: ['change', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] ->copylst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'copy']  ['change', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] [, , , , ]  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'copy'] [, , , , ] 以当lst发生改变的时候,sourceLst和copyLst两个列表就都发生了改变。 [, , , , ] [, , , , ] ->sourcelst: ['change', 'str2', 'str3', ['str1', 'str2', 'str3', 'Append'], 'source'] ->copylst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3', 'Append'], 'copy']  ['change', 'str2', 'str3', ['str1', 'str2', 'str3', 'Append'], 'source'] [, , , , ]  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3', 'Append'], 'copy'] [, , , , ] Process finished with exit code 0 

      刚刚我们了解了浅拷贝的意义,但是在写程序的时候,我们就是希望复杂的数据结构之间完全copy一份并且它们之间又没有一毛钱关系,应该怎么办呢?

    深拷贝

      我们引入一个深拷贝的概念,深拷贝——即python的copy模块提供的另一个deepcopy方法。深拷贝会完全复制原变量相关的所有数据,在内存中生成一套完全一样的内容,在这个过程中我们对这两个变量中的一个进行任意修改都不会影响其他变量。下面我们就来试验一下。

           python深浅拷贝

          看上面的执行结果,这一次我们不管是对直接对列表进行操作还是对列表内嵌套的其他数据结构操作,都不会产生拷贝的列表受影响的情况。我们再来看看这些变量在内存中的状况:

         python深浅拷贝

      看了上面的内容,我们就知道了深拷贝的原理。其实深拷贝就是在内存中重新开辟一块空间,不管数据结构多么复杂,只要遇到可能发生改变的数据类型,就重新开辟一块内存空间把内容复制下来,直到最后一层,不再有复杂的数据类型,就保持其原引用。这样,不管数据结构多么的复杂,数据之间的修改都不会相互影响。这就是深拷贝~~~

  • 对象赋值
    print("深拷贝") import copy lst = ['str1', 'str2', 'str3'] sourcelst = ['str1', 'str2', 'str3', lst] deepcopylst = copy.deepcopy(sourcelst) print("原本地址") print([id(ele) for ele in sourcelst]) print([id(ele) for ele in deepcopylst]) print("当sourceLst列表发生变化,copyLst中存储的lst内存地址没有改变") sourcelst.append('source') deepcopylst.append('deepcopy') print("->sourcelst: ", sourcelst) print("->deepcopylst: ", deepcopylst) print(id(sourcelst)) # 4 print(sourcelst) # 5 print([id(ele) for ele in sourcelst]) print(id(deepcopylst)) # 4 print(deepcopylst) # 5 print([id(ele) for ele in deepcopylst]) print("sourceLst的第一个元素发生了变化。而copyLst还是存储了str1的地址,所以copyLst不会发生改变。") print([id(ele) for ele in sourcelst]) print([id(ele) for ele in deepcopylst]) sourcelst[0] = 'change' print("->sourcelst: ", sourcelst) print("->deepcopylst: ", deepcopylst) print(id(sourcelst)) # 4 print(sourcelst) # 5 print([id(ele) for ele in sourcelst]) print(id(deepcopylst)) # 4 print(deepcopylst) # 5 print([id(ele) for ele in deepcopylst]) print("以当lst发生改变的时候,sourceLst和copyLst两个列表就都发生了改变。") print([id(ele) for ele in sourcelst]) print([id(ele) for ele in deepcopylst]) lst.append('Append') print("->sourcelst: ", sourcelst) print("->copylst: ", deepcopylst) print(id(sourcelst)) # 4 print(sourcelst) # 5 print([id(ele) for ele in sourcelst]) print(id(deepcopylst)) # 4 print(deepcopylst) # 5 print([id(ele) for ele in deepcopylst]) C:\Anaconda3\python.exe H:/python/venv/pizza.py 浅拷贝 原本地址 [, , , ] [, , , ] 当sourceLst列表发生变化,copyLst中存储的lst内存地址没有改变 ->sourcelst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] ->deepcopylst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'deepcopy']  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] [, , , , ]  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'deepcopy'] [, , , , ] sourceLst的第一个元素发生了变化。而copyLst还是存储了str1的地址,所以copyLst不会发生改变。 [, , , , ] [, , , , ] ->sourcelst: ['change', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] ->deepcopylst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'deepcopy']  ['change', 'str2', 'str3', ['str1', 'str2', 'str3'], 'source'] [, , , , ]  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'deepcopy'] [, , , , ] 以当lst发生改变的时候,sourceLst和copyLst两个列表就都发生了改变。 [, , , , ] [, , , , ] ->sourcelst: ['change', 'str2', 'str3', ['str1', 'str2', 'str3', 'Append'], 'source'] ->copylst: ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'deepcopy']  ['change', 'str2', 'str3', ['str1', 'str2', 'str3', 'Append'], 'source'] [, , , , ]  ['str1', 'str2', 'str3', ['str1', 'str2', 'str3'], 'deepcopy'] [, , , , ] Process finished with exit code 0 

直接看一段代码:

import copy will = ["Will", 28, ["Python", "C#", "JavaScript"]] # wilber = copy.deepcopy(will) wilber = will print(id(will)) # 1 print(will) # 2 print([id(ele) for ele in will]) # 3 print(id(wilber)) # 4 print(wilber) # 5 print([id(ele) for ele in wilber]) print("\n") will[0] = "Wilber" will[2].append("CSS") print(id(will)) # 6 print(will) print([id(ele) for ele in will]) print(id(wilber)) print(wilber) print([id(ele) for ele in wilber])

 代码的输出为: 

C:\Anaconda3\python.exe H:/python/venv/pizza.py  ['Will', 28, ['Python', 'C#', 'JavaScript']] [, , ]  ['Will', 28, ['Python', 'C#', 'JavaScript']] [, , ]  ['Wilber', 28, ['Python', 'C#', 'JavaScript', 'CSS']] [, , ]  ['Wilber', 28, ['Python', 'C#', 'JavaScript', 'CSS']] [, , ] Process finished with exit code 0 

 下面来分析一下这段代码:

 

  • 首先,创建了一个名为will的变量,这个变量指向一个list对象,从第一张图中可以看到所有对象的地址(每次运行,结果可能不同)
    • 然后,通过will变量对wilber变量进行赋值,那么wilber变量将指向will变量对应的对象(内存地址),也就是说”wilber is will”,”wilber[i] is will[i]”

可以理解为,Python中,对象的赋值都是进行对象引用(内存地址)传递

  • 第三张图中,由于will和wilber指向同一个对象,所以对will的任何修改都会体现在wilber上

这里需要注意的一点是,str是不可变类型,所以当修改的时候会替换旧的对象,产生一个新的地址

python深浅拷贝

 浅拷贝

import copy will = ["Will", 28, ["Python", "C#", "JavaScript"]] # wilber = copy.deepcopy(will) # wilber = will wilber = copy.copy(will) print(id(will)) # 1 print(will) # 2 print([id(ele) for ele in will]) # 3 print(id(wilber)) # 4 print(wilber) # 5 print([id(ele) for ele in wilber]) print("") will[0] = "Wilber" will[2].append("CSS") print(id(will)) # 6 print(will) print([id(ele) for ele in will]) print(id(wilber)) print(wilber) print([id(ele) for ele in wilber])
C:\Anaconda3\python.exe H:/python/venv/pizza.py  ['Will', 28, ['Python', 'C#', 'JavaScript']] [, , ]  ['Will', 28, ['Python', 'C#', 'JavaScript']] [, , ]  ['Wilber', 28, ['Python', 'C#', 'JavaScript', 'CSS']] [, , ]  ['Will', 28, ['Python', 'C#', 'JavaScript', 'CSS']] [, , ] Process finished with exit code 0 

分析一下这段代码:

  • 首先,依然使用一个will变量,指向一个list类型的对象
  • 然后,通过copy模块里面的浅拷贝函数copy(),对will指向的对象进行浅拷贝,然后浅拷贝生成的新对象赋值给wilber变量
  • 当对will进行修改的时候

由于list的第一个元素是不可变类型,所以will对应的list的第一个元素会使用一个新的对象

但是list的第三个元素是一个可不类型,修改操作不会产生新的对象,所以will的修改结果会相应的反应到wilber上

总结一下,当我们使用下面的操作的时候,会产生浅拷贝的效果:

  • 使用切片[:]操作
  • 使用工厂函数(如list/dir/set)
  • 使用copy模块中的copy()函数
  •  
  • python深浅拷贝

深拷贝

最后来看看深拷贝:

import copy will = ["Will", 28, ["Python", "C#", "JavaScript"]] wilber = copy.deepcopy(will) print(id(will)) # 1 print(will) # 2 print([id(ele) for ele in will]) # 3 print(id(wilber)) # 4 print(wilber) # 5 print([id(ele) for ele in wilber]) will[0] = "Wilber" will[2].append("CSS") print(id(will)) # 6 print(will) print([id(ele) for ele in will]) print(id(wilber)) print(wilber) print([id(ele) for ele in wilber])
C:\Anaconda3\python.exe H:/python/venv/pizza.py  ['Will', 28, ['Python', 'C#', 'JavaScript']] [, , ]  ['Will', 28, ['Python', 'C#', 'JavaScript']] [, , ]  ['Wilber', 28, ['Python', 'C#', 'JavaScript', 'CSS']] [, , ]  ['Will', 28, ['Python', 'C#', 'JavaScript']] [, , ] Process finished with exit code 0 

 分析一下这段代码:

  • 首先,同样使用一个will变量,指向一个list类型的对象
  • 然后,通过copy模块里面的深拷贝函数deepcopy(),对will指向的对象进行深拷贝,然后深拷贝生成的新对象赋值给wilber变量

 跟浅拷贝类似,深拷贝也会创建一个新的对象,这个例子中”wilber is not will”
但是,对于对象中的元素,深拷贝都会重新生成一份(有特殊情况,下面会说明),而不是简单的使用原始元素的引用(内存地址)
例子中will的第三个元素指向,而wilber的第三个元素是一个全新的对象,也就是说,”wilber[2] is not will[2]”

  • 当对will进行修改的时候

 python深浅拷贝

 

拷贝的特殊情况

其实,对于拷贝有一些特殊情况:

  • 对于非容器类型(如数字、字符串、和其他’原子’类型的对象)没有拷贝这一说

也就是说,对于这些类型,”obj is copy.copy(obj)” 、”obj is copy.deepcopy(obj)”

  • 如果元组变量只包含空列表类型对象,则不能深拷贝,看下面的例子
  • import copy books = ("Python", "C#", "java") copies = copy.deepcopy(books) print(books is copies) # 如果元组变量包含空列表类型对象,则不能深拷贝 books = ("Python", "C#", "java", []) copies = copy.deepcopy(books) print(books is copies)

    总结

    C:\Anaconda3\python.exe H:/python/venv/pizza.py True False Process finished with exit code 0 

    本文介绍了对象的赋值和拷贝,以及它们之间的差异:

  • Python中对象的赋值都是进行对象引用(内存地址)传递
  • 使用copy.copy(),可以进行对象的浅拷贝,它复制了对象,但对于对象中的元素,依然使用原始的引用.
  • 如果需要复制一个容器对象,以及它里面的所有元素(包含元素的子元素),可以使用copy.deepcopy()进行深拷贝
  • 对于非容器类型(如数字、字符串、和其他’原子’类型的对象)没有被拷贝一说
  • 如果元组变量只包含空列表类型对象,则不能深拷贝
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/231049.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • D3js快速入门——用最新版D3js实现树图

    D3js快速入门——用最新版D3js实现树图文章目录 引言 1 D3js 是什么 2 D3js 相对其他数据可视化方案的优势 2 1SVG 对比 Canvas2 2D3 js 对比 Echarts3 怎么用 D3 js 开发一个树图 3 1 前置基础 3 2d3 开发树图流程 3 3 动手实现一个树图 3 3 1 普通 tidetree3 3 2 你的树图不简单 radiotidetre 3 3 更多可能 更多类型的树图引言上周我们组新开项目 技术调研之后决定使用 d3 js 做数据可视化开发 mentor 让我来做初期技术调研 之后的技

    2025年10月24日
    4
  • 记一道USB流量分析CTF题

    记一道USB流量分析CTF题USB流量分析

    2022年5月20日
    44
  • spring的事务隔离级别「建议收藏」

    spring的事务隔离级别「建议收藏」spring的事务隔离级别

    2022年4月22日
    49
  • nofollow标签浪费了多少站长做外链的时间

    nofollow标签浪费了多少站长做外链的时间

    2021年11月17日
    36
  • java 函数式编程(java自定义函数)

    以前写过一篇java8的流操作,人们都说流操作是函数式编程,但函数式编程是什么呢?什么是函数式编程什么是函数式编程?它是一种编程范式,即一切都是数学函数。函数式编程语言里也可以有对象,但通常这些对象都是恒定不变的——要么是函数参数,要什么是函数返回值。函数式编程语言里没有for/next循环,因为这些逻辑意味着有状态的改变。相替代的是,这种循环逻辑在函数式编程语言里是通过递归、把函…

    2022年4月18日
    57
  • wine卡住_Ubuntu微信

    wine卡住_Ubuntu微信UbuntuwineQQ卡死前几天在Ubuntu下写基因组信息学实验报告用wps-linux转pdf遇到了字体问题,就把windows字体拷过来安装了然后再用QQ就出现一堆口口口口。。。但是这个不影响使用影响使用的是他会卡死。。原因字体缓存没更新解决方案删除windows字体嫌麻烦我就没删。。或者可以:重建缓存cd/usr/share/fontssudofc-cache-fv应该解决了。后续好像还是会卡想到上次安装字体的时候有一堆报错部分截图

    2025年9月19日
    8

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号