# print输出的几种用法

#用法1:用于输出单个字符串或单个变量
print('hey, u')

#用法2:用于输出多个数据项,用逗号分隔
print('hey','u')
x,y,z=1,2,3
print(x, y, z)

#用法3:用户混合字符串和变量值
print('x=%d, y=%d, z=%d'%(x,y,z)) #方式1:传统c风格
print('x = {}, y = {}, z = {}'.format(x,y,z)) # 方式2:s.format()方法
print(f'x = {x}, y = {y},z = {z}') #方式3:f-string方式
# 其它:输出后是否换行

print(x) #默认输出后换一行
print(y)
print(z)

print(x, end=' ') #输出结束后,不换行;通过end指定数据项之间的分隔符print(y,end='')
print(y, end=' ')
print(z)

 


x1, y1 = 1.2, 3.57
x2, y2 = 2.26, 8.7
print('{:-^40}'.format('输出1'))
print('x1 = {}, y1 = {}'.format(x1, y1))
print('x2 = {}, y2 = {}'.format(x2, y2))
print('{:-^40}'.format('输出2'))
print('x1 = {:.1f}, y1 = {:.1f}'.format(x1, y1))
print('x2 = {:.1f}, y2 = {:.1f}'.format(x2, y2))
print('{:-^40}'.format('输出3'))
print('x1 = {:<15.1f}, y1 = {:<15.1f}'.format(x1, y1))
print('x2 = {:<15.1f}, y2 = {:<15.1f}'.format(x2, y2))
print('{:-^40}'.format('输出4'))
print('x1 = {:>15.1f}, y1 = {:>15.1f}'.format(x1, y1))
print('x2 = {:>15.1f}, y2 = {:>15.1f}'.format(x2, y2))
 

name1, age1 = 'Bill', 19
name2, age2 = 'Hellen', 18
title = 'Personnel Information'
print(f'{title:=^40}')
print(f'name: {name1:10}, age: {age1:3}')
print(f'name: {name2:10}, age: {age2:3}')

 


print(40*'=')