python函数模块导入使用问题,为什么会提示这个错误

代码货栈 其他问答 1

模块名:printing_functions.py

def print_models(unprinted_designs,completed_models):
    """
    模拟打印每个设计,直到没有未打印的设计为止。
    打印每个设计后,都将其移到列表completed_models中。
    """
    while unprinted_designs:
        current_design = unprinted_designs.pop()
        print(f"Printing model:{current_design}")
        completed_models.append(current_design)

def show_completed_models(completed_models):
    """显示打印好的所有模型"""
    print("\nThe folloeing models have been printed:")
    for completed_model in completed_models:
        print(completed_model)

导入模块

from printing_functions import print_models,show_completed_models

unprinted_designs = ['phone case','robot pendant','dodecahedron']
show_completed_models = []

printing_functions.print_models(unprinted_designs,completed_models)
printing_functions.show_completed_models(completed_models)

回复

共2条回复 我来回复
  • 代码海岸
    这个人很懒,什么都没有留下~
    评论
    //如果要这样import
    from printing_functions import print_models,show_completed_models
    
    //那要这样用
    print_models(unprinted_designs,completed_models)
    show_completed_models(completed_models)
    
    0条评论
  • 毕设货栈
    这个人很懒,什么都没有留下~
    评论
    print_models(unprinted_designs,completed_models)
      show_completed_models(completed_models)
    
    0条评论

发表回复

登录后才能评论