import os
from Common.Log_common import LOG
#封装一个循环方法
class userLogin():
list1 = []
def login(self):
with open('D:\\Pycharm\\MyApi_demo\\user.txt', encoding='utf-8')as f1:
for value in f1.readlines():
every_user = str(value) # 每一行的值,每一个值的后面会有一个换行f
userLogin.list1.append(every_user)
for user in userLogin.list1:
if not user.startswith("#"):
user_list = user.split(' ')
uid = user_list[0]
password = user_list[1] # 取到了不以#开头的账号和密码
index = userLogin.list1.index(user) # 取一下索引
break
# 这里写登录的请求
print(uid)
print(password)
userLogin.list1[index] = '#' + user # 改变文本的内容
# 申请一个流,重新写入文本
f1.close()
def change_user():
with open('D:\\Pycharm\\MyApi_demo\\user.txt', 'w', encoding='utf-8', )as f2:
f2.writelines(userLogin.list1)
f2.close()
if __name__=='__main__':
login=userLogin()
login.login()
change_user()
#然后在caselist相同路径下 放txt
#user1 123
user2 123
user3 123
user4 123
user5 123