import pyautogui
import keyboard
import datetime
now=datetime.datetime.now()
day = now.strftime('%j')
week = now.strftime('%U')
month = now.strftime('%m')
year = now.strftime('%y')
def code():
while True:
code = pyautogui.password(text='请输入密码', title='登录', default='', mask='*')
if code == day*3 or week*3 ....... :
pyautogui.alert(text='欢迎使用', title='登录', button='OK')
break
else:
pyautogui.alert(text='密码错误', title='登录', button='OK')
exit()
if __name__ == '__main__':
code()
想以date×数字 获得一串根据时间变化的无序密码,请问需要怎么改动,自学能力有限. 解决追加10元
参考GPT的内容和自己的思路:
您可以使用 strftime() 函数将日期时间对象转换为字符串,然后使用乘法运算符将其与数字相乘。
下面是一个例子,将日期乘以数字后转换为字符串,并将其用作密码。
import datetime
now = datetime.datetime.now()
day = int(now.strftime('%j'))
week = int(now.strftime('%U'))
month = int(now.strftime('%m'))
year = int(now.strftime('%y'))
password = str(day * 9) + str(week * 9) + str(month * 9) + str(year * 9)
print(password)
这将生成一个由日期乘以9得到的数字组成的字符串作为密码。然后您可以将其用作输入密码的一部分,来控制可使用的时间。注意,这只是一个简单的例子,您需要根据您的需求来修改和调整代码。
直接使用strftime()方法来将时间日期转换为字符串,并使用int()方法将字符串转换为整数:
import pyautogui
import datetime
now=datetime.datetime.now()
day = int(now.strftime('%j'))
week = int(now.strftime('%U'))
month = int(now.strftime('%m'))
year = int(now.strftime('%y'))
def code():
while True:
code = pyautogui.password(text='请输入密码', title='登录', default='', mask='*')
if code == str(day*9) or code == str(week*9) or code == str(month*9) or code == str(year*9):
pyautogui.alert(text='欢迎使用', title='登录', button='OK')
break
else:
pyautogui.alert(text='密码错误', title='登录', button='OK')
exit()
if __name__ == '__main__':
code()