下例能将关键字参数顺序不重要展示得更清楚:
实例(Python 2.0+)
#!/usr/bin/python# -*- coding: UTF-8 -*-#可写函数说明defprintinfo(name, age): "打印任何传入的字符串" print"Name: ", name print"Age ", age return#调用printinfo函数printinfo(age=50, name="miki")
以上实例输出结果:
Name: miki
Age 50
下例能将关键字参数顺序不重要展示得更清楚:
#!/usr/bin/python# -*- coding: UTF-8 -*-#可写函数说明defprintinfo(name, age): "打印任何传入的字符串" print"Name: ", name print"Age ", age return#调用printinfo函数printinfo(age=50, name="miki")
以上实例输出结果:
Name: miki
Age 50