numbers = (1,2,3)
元组里面的项目不可以修改 (用圆括号)
2. 解压缩
- coordinates = (1,2,3)
- x,y,z = coordinates
- print(x,y,z)
- >>1 2 3
3. 字典
- customer = {
- "name" : "John smith",
- "age" : 30,
- "is_verified":True
- }
- print(customer["name"])
- >> John smith
4. 按空格分割
- message = input (">")
- words = message.split(' ')
- print(words)
- >Good morning
- ["Good" , "morning"]
5. 函数
- def greet_user():
- print('Hi there!')
- print('Welcome aboard')
- print('Start')
- greet_user()
- print("Finish")
函数后面需要空两行
来源: http://www.bubuko.com/infodetail-3353426.html