def 定義function

def varalex():
    print 'hello beauty'

varalex()

# Result:

hello beauty

 

 

def varalex(usealex):

 

    print 'hello beauty %s' %usealex

varalex('u look so beauty')

# Result:

hello beauty u look so beauty

 

 

def varalex(usealex):

 

    for i in usealex:

        print 'hello beauty %s' %i

varalex(['funny', 'ball', 'child', 'car', 'girl'])

# Result:

hello beauty funny

hello beauty ball

hello beauty child

hello beauty car

hello beauty girl

 

 

def varalex(usealex):

    chralex = ''

    for i in usealex:

        chralex += 'hello beauty %s\n' %i

    return chralex

alexvar = varalex(['funny', 'ball', 'child', 'car', 'girl'])

print alexvar

# Result:

hello beauty funny

hello beauty ball

hello beauty child

hello beauty car

hello beauty girl

arrow
arrow
    文章標籤
    python
    全站熱搜

    A咖來D賽 發表在 痞客邦 留言(0) 人氣()