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];

 

posted @ 2015-07-02 22:26  nick_huang  阅读(286)  评论(0)    收藏  举报