国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Python > 正文

python如何實現不用裝飾器實現登陸器小程序

2024-09-09 19:03:18
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了python如何實現不用裝飾器實現登陸器小程序,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

下面代碼演示了不使用裝飾器實現用戶登陸功能的小程序,在python3.x下可正常運行

#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Tue Nov 26 15:26:58 2019@author: root"""def menu():  print('choice'.center(50,'-'))  msg = '''  1. home  2. finance  3. book  4. exit  '''  print(msg)  print("".center(50,'-')) def login(login_flat,choice):  if not login_flat:    while True:      username = str(input("username:"))      password = str(input("password:"))      if choice == '1':        home()        with open('jingdong.txt','r') as f1:          for line in f1:            element = line.split(" ",1)            print(element[0])            print(element[1])            if username.strip() == element[0].strip() and password.strip() == element[1].strip():              print("log in successful!")              return True            print("failed to log in!,try it again!")      elif choice == '2':        finance()        with open('weixin.txt','r') as f2:          for line in f1:            element = line.split(" ",1)            if username.strip() == element[0].strip() and password.strip() == element[1].strip():              print("log in successful!")              return True            print("failed to log in!,try it again!")         elif choice == '3':        book()        with open('jingdong.txt','r') as f3:          for line in f3:            element = line.split(" ",1)            if username.strip() == element[0].strip() and password.strip() == element[1].strip():              print("log in successful!")              return True            print("failed to log in!,try it again!")                else:    print("You have logged in before!")    return True#@login(login_flat,choice)            def home():  print("home.....")#@login(login_flat,choice) def finance():  print("finance.....")#@login(login_flat,choice) def book():  print("book.....")  login_flag = Falsewhile True:  menu()  choice = input("your choice:")  if choice == '1':    login_flag = login(login_flag,choice)  elif choice == '2':    login_flag = login(login_flag,choice)  elif choice == '3':    login_flag = login(login_flag,choice)  elif choice == '4':    print('bye-bye')    break  else:    print("wrong input ,try it again!")

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網之家。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定襄县| 昌邑市| 长寿区| 长宁县| 鲁甸县| 凤凰县| 南安市| 阿图什市| 冷水江市| 莱阳市| 绥江县| 普陀区| 新蔡县| 南阳市| 高青县| 格尔木市| 房产| 休宁县| 铜川市| 华亭县| 永清县| 永定县| 海安县| 漳平市| 双柏县| 金湖县| 宁海县| 田阳县| 临沭县| 阿尔山市| 定南县| 文昌市| 梅河口市| 阳谷县| 前郭尔| 钟祥市| 达尔| 邯郸县| 永寿县| 澄城县| 交口县|