Python 2.7.9 Demo - 020.函数的定义、返回

 

#coding=utf-8

#!/usr/bin/python



def setConfig():

    hello = 'world';

    print 'The value has been setted.';

    return hello;

    

hello_cp = setConfig();

print 'print outside : ' + hello_cp;

 

#coding=utf-8

#!/usr/bin/python



def setConfig():

    dict = {'username' : 'nick huang', 'age' : 18};

    print 'The value has been setted.';

    return dict;

    

dict_cp = setConfig();

print 'print outside : ';

for key in dict_cp.keys():

    print dict_cp[key];

 

你可能感兴趣的:(python)