zoukankan      html  css  js  c++  java
  • 04-python第四天学习

    (1)for循环里的else

    In [1]: nums = [11,22,33,44]
    
    In [2]: for temp in nums:
       ...:     print(temp)
       ...: else:    #else表示当循环打印完才会打印else里的内容
       ...:     print("========")
       ...:     
    11
    22
    33
    44
    ========

    (2)列表append的注意点

    In [3]: a = [11,22,33]
    
    In [4]: b = [44,55]
    
    In [5]: a.append(b)
    
    In [6]: a
    Out[6]: [11, 22, 33, [44, 55]]  #append相当于把b列表这个整体都放在a列表
    In [1]: a = [11,22,33]
    
    In [2]: b = [44,55]
    
    In [3]: a.append(b)
    
    In [4]: a
    Out[4]: [11, 22, 33, [44, 55]]
    
    In [5]: a = a.append(b)  #当执行a.append(b)时,代表已经把b添加到a里面去了,结果已经发生了变化,但是a.append(b)并没有结果输入,则会返回空
    
    In [6]: a
  • 相关阅读:
    数论2&莫&杜
    虚树学习笔记
    LinkCutTree学习笔记
    FWT学习笔记
    容斥
    线段树合并
    线性基
    FFT_应用和例题
    斜率优化
    Redis中String的底层实现
  • 原文地址:https://www.cnblogs.com/xiaoyafei/p/8539053.html
Copyright © 2011-2022 走看看