python编程面试题
Posted teachertao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python编程面试题相关的知识,希望对你有一定的参考价值。
# 实现需求为 注册、登录、查看昵称的功能
# def userN():
# username = input("请输入账号:
")
# password = input(‘请输入密码:
‘)
# return username,password
# def register():
# # 注册函数封装
# username,password= userN()
# temp = username + "|" + password
# with open(‘D:Test_Pythonlogin.md‘,‘w‘) as file:
# file.write(temp)
# def login():
# # 登录函数封装
# username,password= userN()
# with open(‘D:Test_Pythonlogin.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_Pythonlogin.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
以上是关于python编程面试题的主要内容,如果未能解决你的问题,请参考以下文章