创建python列表
方法一:直接创建列表
a = [1, 2, 3, 4, 5]
print(a)
/usr/local/bin/python3.8 /Users/sataniya/PycharmProjects.../demo/demo.py
[1, 2, 3, 4, 5]
方法二:使用list方法
a = list("hello")
print(a)
/usr/local/bin/python3.8 /Users...print(a)
/usr/local/bin/python3.8 /Users/sataniya/PycharmProjects/demo/demo.py
['hello', 'world']
方法四:使用列表推导式...x in range(10)]
print(a)
/usr/local/bin/python3.8 /Users/sataniya/PycharmProjects/demo/demo.py
[0, 1,