Phtyon学习笔记
错误笔记
name = “Downey”
print(f"My name is {name}“)
print(f”{name} is a good boy")
print(f"{name} likes playing football")
#f后面不能有空格
name = "Downey"
print(f"My name is {name}")
print(f"{name} is a good boy")
print(f"{name} likes playing football")
#f后面不能有空格
元组(数据不可修改)
tupleOne = (0,1,2,3,4,5,6)
列表(可修改)
players = ["小叮当", "qian", "Tang", "Max", "杰老板", "飞飞"]
print(players)
切片(左闭右开 )
print(players[0:3])
someNames = ["小叮当", "qian", "Tang", "Max", "杰老板", "飞飞"]
print(someNames[1:6])
players = ("Tang", "Max", "飞飞", 123, 66, 52.3)
print(players[:3])
print(players[3:])
元组、列表追加语句 append()
# 设置列表fruit和列表tropics
fruit = ["apple", "grape", "cherry"]
tropics = ["banana", "mango"]
# 往列表fruit中追加列表tropics
fruit.append(tropics)
# 使用print()输出fruit
print(fruit)
[‘apple’, ‘grape’, ‘cherry’, [‘banana’, ‘mango’]]
列表的插入insert
列表的删除pop
primeNumber.pop() 括号内的数字表示要删除数据的索引,不填写数字则表示默认删除列表中的最后一个数据。