函数笔记

104 阅读1分钟

函数:封装一系列的代码,用于实现某种特定的功能

def showHello():

for index in range(0, 10):

print("hello world")

showHello()

showHello()

函数的定义

参数列表 和return 根据需求添加

参数:拓展函数功能

def 函数名称(参数列表):

函数体内容

return 返回值:函数运行之后的返回结果,如果不写直接返回none

def showHello(count): for index in range(0, count): print("hello world") return "ok"

showHello(25)

int() 转化为整型

x = '11'

y = int(x)

print(y)

x = showHello(1) print(x)