Abyss_QQ 2021-06-04 13:53 采纳率: 100%
浏览 52
已采纳

python,请问如何将函数内的返回值,调入进下一函数中

如何将start函数中的返回值origina_code,调入进sys函数中呢?

最后这样调用会将start函数执行两次,有时还会执行错误。

 

def start_system():
    print("Please input your student number: \n")
    input("Your student number:\n")
    print("Please input your code:\n")
    original_code = int(input("Your code:"))

    print("Welcome come to student system")
    print("---------------Student System---------------")
    print("     1.更改信息                 2.更改账号" + "\n"
          "     3.更改密码                 4.删除账号" + "\n"
          "     5.添加选课                 6.退出系统" + "\n"
          )
    print(original_code)
    return original_code


def sys_choice(operation_a, original_code):
    if operation_a == 1:
        input("Please input your old information:")
        input("Input your new information:")
        print("Mission success!")

    elif operation_a == 2:
        print("You have not access to achieve this operation!")

    elif operation_a == 3:
        original_code1 = int(input("Please input your original code:"))
        if original_code1 == original_code:
            new_code1 = int(input("Input your new code:"))
            new_code2 = int(input("Make sure your new code:"))
            if new_code2 == new_code1:
                print("Operation is successful !")
            else:
                print("Error !, your input is different !")
        else:
            print("input is error !")

    elif operation_a == 4:
        print("Do you delete your number?")
        choice4 = input("Please input your choice:")
        if choice4 == 'y':
            print("OK")
        else:
            print("Error !")

    elif operation_a == 5:
        print("choose your course:")

    elif operation_a == 6:
        choice6 = input("Are you sure log out the student system ?")
        if choice6 == 'y' or 'yes':
            print("Exit the success !")
        elif choice6 == 'n' or 'no':
            print("Cancel out !")

    else:
        print("Your input is error. Please input your choice again.")



'''如何让start返回code进入到sys中'''

start_system()
print("----------------\n")
operation_a = int(input("Make your choice:"))
sys_choice(operation_a, original_code=start_system())
  • 写回答

3条回答 默认 最新

  • PythonJavaC++go 2021-06-04 14:33
    关注
    start_system()
    print("----------------\n")
    operation_a = int(input("Make your choice:"))
    sys_choice(operation_a, original_code=start_system())
    
    
    # 最后这4行更改如下
    
    original_code = start_system()
    print("----------------\n")
    operation_a = int(input("Make your choice:"))
    sys_choice(operation_a, original_code)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择