文章

Python 从入门到实践 8.15-17章及习题

printing_functions.py的代码

def print_models(unprinted_designs,completed_models):
	while unprinted_designs:
		current_design = unprinted_designs.pop()
		print("printing model: "+current_design)
		completed_models.append(current_design)
		
def show_complete_models(completed_models):
	print("\nthe following models have been printed:")
	for completed_model in completed_models:
		print(completed_model)

print_models.py的代码

#coding:gbk
import printing_functions as f
unprinted_designs=['iphone case','robot pendant','dodecahedron']
completed_models=[]

f.print_models(unprinted_designs,completed_models)
f.show_complete_models(completed_models)

from print_fuctions import show_complete_models
from print_fuctions import show_complete_models as scm
from print_fuctions import show_complete_models *


本章将函数存储在模块中进行调用,所以分了两个文件

原文来自:Python 从入门到实践 8.15-17章及习题,尊重自己,尊重每一个人;转发请注明来源!
0 0

发表评论