摘要: 1、列表中嵌套字典 a1 = {'color':'green', 'points':5}a2 = {'color':'yello', 'points':25}a3 = {'color':'red', 'points':15} ass = [a1, a2, a3] for a in ass: prin 阅读全文
posted @ 2020-11-10 15:48 Ruigel1 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 函数的有点之一是,使用他们可将代码块与主程序分离。通过给函数指定描述性名称,可以让主程序容易理解的多。 还可以将函数存储在被称为模块的独立文件,再将模块导入到主程序中。 import语句允许在当前运行的程序文件中使用模块中的代码。 通过将函数存储在独立的文件中,可隐藏程序代码的细节,将重点放在程序的 阅读全文
posted @ 2020-11-10 15:43 Ruigel1 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 1、定义函数 示例代码 def greef_user(): print("Hello!") greef_user() 结果: 2、传递任意数量的实参(*) 示例代码: def build_profile(*user_info): for name in user_info: print(name) 阅读全文
posted @ 2020-11-10 15:02 Ruigel1 阅读(68) 评论(0) 推荐(0) 编辑