What does += mean in Python?

后端 未结 6 500
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 08:29

I see code like this for example in Python:

    if cnt > 0 and len(aStr) > 1:
        while cnt > 0:                  
            aStr = aStr[1:]+a         


        
6条回答
  •  鱼传尺愫
    2020-12-01 09:28

    it means "append "THIS" to the current value"

    example:

    a = "hello"; a += " world";

    printing a now will output: "hello world"

提交回复
热议问题