python创建列表方法讲解
程序员文章站
2024-01-01 21:49:46
创建列表
方法一:
实例一:
a = [1,2,3,4,5,6]
print(a)
打印结果如下:
D:\python3.5\python.exe D:/pycharm...
创建列表
方法一:
实例一:
a = [1,2,3,4,5,6]
print(a)
打印结果如下:
D:\python3.5\python.exe D:/pycharm/data/第一周/day3/集合.py
[1, 2, 3, 4, 5, 6]
实例二:
a = [1,2,3,4,5,6,['zhang','jun','chao']]
print(a)
打印结果如下:
D:\python3.5\python.exe D:/pycharm/data/第一周/day3/集合.py
[1, 2, 3, 4, 5, 6, ['zhang', 'jun', 'chao']]
方法二:
实例一:
a = list([1,2,3,4,5,6])
print(a)
打印结果如下:
D:\python3.5\python.exe D:/pycharm/data/第一周/day3/集合.py
[1, 2, 3, 4, 5, 6]
实例二:
a = list([1,2,3,4,5,6,['zhang','jun','chao']])
print(a)
打印结果如下:
D:\python3.5\python.exe D:/pycharm/data/第一周/day3/集合.py
[1, 2, 3, 4, 5, 6, ['zhang', 'jun', 'chao']]