Python list initialization

a = [1, 2, 3]
b = [1, 2, 3,]

I don"t understand. What"s the difference between the two arrays? There are a lot of arrays in django that end with a comma. Ask for advice

Mar.10,2021

is there such a thing? I know that tuple needs to be added when there is only one element, and whether list is added or not is the same.


a=[1,2,3]
b=[1,2,3,]
print(a)
print(b)
print(a==b)
a.append(1)
b.append(1)
print(a)
print(b)
print(a==b)
def test(c):
    print(type(c))
test((1,))
test((1))
test(a)
test(b)

there is no difference between the two results, but when passing parameters to the function, Python will do different processing
such as (12) and (12,), but there is no difference in passing parameters in the list. The running result is as follows

.
[Running] python "e:\Rare\python\demo_1\demo_1.py"
[1, 2, 3]
[1, 2, 3]
True
[1, 2, 3, 1]
[1, 2, 3, 1]
True
<class 'tuple'>
<class 'int'>
<class 'list'>
<class 'list'>

[Done] exited with code=0 in 0.116 seconds
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9a645-17d1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9a645-17d1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?