print("my name is {}").format("Tony");
print("my name is {0}").format("tony");
print("my name is {name}").format(name="tony");
class simply:
def __init__(self,dic):
print self.__dict__.update(dic);
def __str__(self):
return "my name is {self.name} this year age {self.age}".format(self=self);
s = simply({"name":"jack","age":18});
p = ["xxx",19];
print ("{0[0]} {0[1]}").format(p);
print ("{:>8}").format(186);
print ("{:<8}").format(186);
print ("{:^8}").format(186);
print ("{:0>8}").format(186);
print ("{:.2f}").format(186.3223);
print ("{:b}").format(100);
print ("{:o}").format(100);
print ("{:x}").format(100);
print ("{:d}").format(100);
print ("{:,}").format(1861231321);
具体用法请参考:http://blog.youkuaiyun.com/handsomekang/article/details/9183303
957

被折叠的 条评论
为什么被折叠?



