1 变量
赋值:变量可以是字符串、序列、元组、
# author:hams.ali # 界面
line = '-*'*20
# 数字直接可以计算 _var1 = '' # 字符变量拼接
_var_2 = '\n\tmy age is ' + _var1 # 不可改变数值的组元
var = (2019, 9, 27) # 变量解压
x , y ,z=(2019, 9, 17)
print(x,y,z)
print(line)# 分割
# 多变量解压
data = ['ali', 'english', 65, (2019, 9, 17)]
name, subjet, soce, (year, moth, day) = data
print('name', 'subjet', 'soce', 'year', 'moth', 'day')
print(name, subjet, soce, '\t', year, moth, day)
print(line)# 分割 record = ['Dave', 'dave@example.com', '773-555-1212', '847-555-1212']
name, email, *phone_numbers = record
print('name:{}\nemail:{}\nphone:{}'.\
format(name, email, phone_numbers))
print(line)# 分割
输出效果:
2019 9 17
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
name subjet soce year moth day
ali english 65 2019 9 17
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
name:Dave
email:dave@example.com
phone:['773-555-1212', '847-555-1212']
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*