字典和format用法

#_*_ encoding: utf-8 _*_   @author: ty  hery   2019/9/6

def table_things(**kwargs):
    for name, value in kwargs.items():
        print ('{0} = {1}'.format(name, value))

table_things(apple = 'fruit', cabbage = 'vegetable')
输出:
apple = fruit
cabbage = vegetable
#_*_ encoding: utf-8 _*_   @author: ty  hery   2019/9/6

def print_three_things(a, b, c):
    print ('a = {0}, b = {1}, c = {2}'.format(a,b,c))

mylist = ['aardvark', 'baboon', 'cat']
print_three_things(*mylist)
mylist2 = ('aardvark', 'baboon', 'cat')
print_three_things(*mylist)
print_three_things(a = 'aardvark', b = 'baboon', c = 'cat')
输出:
a = aardvark, b = baboon, c = cat
a = aardvark, b = baboon, c = cat
a = aardvark, b = baboon, c = cat
上一篇:js阻止事件冒泡


下一篇:python字典之fromkeys()方法