#字符串拼接
#str.join(元组、列表、字典、字符串) 之后生成的只能是字符串。
str = "-";
seq = ("a", "b", "c"); # 字符串序列
sqr=[‘a‘,‘b‘,‘c‘,‘sss‘]#list
ssr=str.join(sqr)
print(‘=‘.join(ssr))
print (str.join(sqr));
print (str.join(seq));
seq = {‘hello‘:‘nihao‘,‘good‘:2,‘boy‘:3,‘doiido‘:4}#对象
print(‘-‘.join(seq))
#打印字符
print ("His name is %s"%("Aviad"))#1. 打印字符串
#http://www.cnblogs.com/plwang1990/p/3757549.html
print ("He is %d years old"%(25))#2.打印整数
print ("His height is %f m"%(1.83))#3.打印浮点数
print ("His height is %.2f m"%(1.83))#4.打印浮点数(指定保留小数点位数)
print ("Name:%10s Age:%8d Height:%8.2f"%("Aviad",25,1.83))#5.指定占位符宽度
print ("Name:%-10s Age:%-8d Height:%-8.2f"%("Aviad",25,1.83))#6.指定占位符宽度(左对齐)
print ("Name:%-10s Age:%08d Height:%08.2f"%("Aviad",25,1.83))#7.指定占位符(只能用0当占位符?)
原文地址:https://www.cnblogs.com/tallme/p/9490848.html