問:那些是Python的文字媲美JavaScript的文字?
JS objects are comparable to Python dicts
JS arrays are comparable to Python arrays
問:是否有更多的Python數據結構文字?
Yes.
Python has tuples: (10, 20, 30)
Python has sets: {10, 20, 30}
問:有字典文字和字典(...)有什麼區別?
If you mean, a difference between JS and Python, the answer is Yes.
JS dictionaries (objects) must have a string as a key.
Python can use other types as a key.
JS object literals do not allow a trailing comma.
If you mean, a difference between Python literals and the dict() constructor,
the answer depends on how you use the dict contructor.
dict(a=1, b=2) # only allows keys to be valid identifiers that aren't keywords
dict([('x y', 0), ('def', 1), (12, 'tw')]) # is more flexible
{'x y': 0, 'def': 1, 12: 'tw'} # is flexible and equivalent
P.S.
The are other JS versus Python differences besides the containers.
Python has "True". JS has "true"
Python has "None". JS has "none"
Python has four string quoting characters: ' " ''' """
爲什麼Python文字不能與JavaScript文字相比? –
爲什麼Python代碼不能在JavaScript中工作,反之亦然? – SethMMorton