python編程面試題



# 實現需求為 注冊、登錄、查看昵稱的功能

# def userN():
#     username = input("請輸入賬號: \n")
#     password = input('請輸入密碼: \n')
#     return username,password


# def register():
#     # 注冊函數封裝
#     username,password= userN()
#     temp = username + "|" + password
#     with open('D:\Test_Python\login.md','w') as file:
#         file.write(temp)


# def login():
#     # 登錄函數封裝
#     username,password= userN()
#     with open('D:\Test_Python\login.md') as file:
#         user = file.read().split("|")
#     if username == user[0] and password == user[1]:
#         return '登錄成功'
#     else:
#         return '登錄失敗,請檢查賬號或者密碼'

# def getNick(func):
#     # 查看個人主頁
#     with open('D:\Test_Python\login.md') as file:
#         user = file.read().split("|")
#     if func:
#         print('{}您好,歡迎再次回來!'.format(user[0]))
#     else:
#         print('您為進行登錄,請登錄!')

# def exit():
#     # 退出系統
#     import sys
#     print('系統已退出,歡迎下次再登錄!')
#     sys.exit(1)
    

# def Main():
#     while True:
#         put = int(input('請選擇 1.注冊 2.登錄 3.退出系統'))
#         if put == 1:
#             register()
#         elif put == 2:
#             getNick(login())
#         elif put == 3:
#             exit()
#         else:
#             print('輸入錯誤,請重新輸入...')
#             continue


# if __name__ == '__main__':
#     Main()
    

# [python編程]
# 列表a = [1,2,3,4,5,6,7],將列表a的值賦給列表b,在不影響列表a的情況下,
# 將列表b的值每間隔一個元素替換成6

# import copy
# a = [1,2,3,4,5,6,7]
# b = a[:]
# items = len(b)
# for i in range(1,items):
#     # print(i)
#     if i%2==0:
#         # print(i)
#         b[i] = 6
# print(a)
# print(b)
# [1, 2, 3, 4, 5, 6, 7]
# [1, 2, 6, 4, 6, 6, 6]

# [python編程]
# 讓用戶輸入用戶密碼,成功打印歡迎信息,輸錯提示還剩幾次機會,三次機會仍然錯誤退出程序

# times = 3
# while times>0:
#     user = input('請輸入用戶名:')
#     pwd = input('請輸入密碼:')
#     if user =='admin' and pwd =='admin':
#         print('歡迎進入KZ系統')
#         if times != 0:
#             print('您還剩'+str(times-1)+'次機會')
#         else:
#             pass
#     else:
#         if user == 'Admin' and pwd == '':
#             print('密碼錯誤')
#             if times != 0:
#                 print('您還剩'+str(times-1)+'次機會')
#             else:
#                 pass
#         else:
#             print('輸入有誤')
#             if times != 0:
#                 print('您還剩'+str(times-1)+'次機會')
#                 # continue
#             else:
#                 break
#     times -= 1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM