网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

python函数入门基础

时间:2024-11-01 21:43:09

1、type(x)返回x的变量类型

python函数入门基础

3、自定义函数和函数调用:def print_lyrics(): print('你好') print('你吃饱了吗')print_lyrics()先定义,再调用,顺序不可颠倒。

python函数入门基础

5、全局变量和局部变量:# -*- coding: utf-8 -*- #先写一下编码格式#定义俩全局变量ahead = '欢迎你'showList = []#做三个自定义函数:def printAhead(): print (ahead)def printOther(): city = '北京' #这里,city是局部变量 print (city + ahead)#此时运行不会有任何返回。想要得到结果,需要调用函数:printAhead() printOther()

python函数入门基础
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com