t=12,34,"avbcdf";
m,n,s=t;
按一定格式或模板占位符,打印出来
print(m,n,s);#print(n); print(s);
print("m is {0} and n is {1} and s is {2}".format(m,n,s));
print("m is {} and n is {} and s is {}".format(m,n,s));
print("m is {m} and n is {n} and s is {s}".format(m=2,n=3,s=9));
print("m is {} and n is {} and s is {s}".format(2,3,s=9));
import math;
print("{0:.3f}".format(math.pi));
table = {‘Sjoerd‘: 4127, ‘Jack‘: 4098, ‘Dcab‘: 8637678}
print(‘Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d};Dcab: {0[Dcab]:d}‘.format(table))
for name,number in table.items():
print("name is {0} and number is{1:10d}".format(name,number));
#json 序列化
import json;
js=json.dumps([1, ‘simple‘, ‘list‘]);
print(js);
print(type(js));
arra=[1, ‘simple‘, ‘list‘];
path="D:\\a.txt";
#r+表示同时具备读写
f = open(path, ‘r+‘)
f.write(‘01wwwfefefef234fdfsadfsfsd56789abcdef‘)
#将序列化写时文件中
json.dump(arra,f);
#json反列化
arra_new=json.load(f);
print(arra_new);
print(type(arra_new));
原文:http://www.cnblogs.com/airven/p/4963007.html