What is the difference between curly brace and square bracket in Python?

前端 未结 3 1240
闹比i
闹比i 2020-12-12 12:44

what is the difference between curly brace and square bracket in python?

A ={1,2}
B =[1,2]

when I print A and B o

3条回答
  •  遥遥无期
    2020-12-12 13:27

    They create different types.

    >>> type({})
    
    >>> type([])
    
    >>> type({1, 2})
    
    >>> type({1: 2})
    
    >>> type([1, 2])
    
    

提交回复
热议问题