为了账号安全,请及时绑定邮箱和手机立即绑定

如何将变量添加到pynput

如何将变量添加到pynput

智慧大石 2023-04-18 16:00:37
#import modulesfrom pynput.keyboard import *import timeimport pyautogui#Ask user for ID and PassID = int(input('Enter ID: '))Pass = int(input('Enter Pass: '))#Enable controllerk = Controller()#Press and Release 'win.key'k.press(Key.cmd)k.release(Key.cmd)time.sleep(1)#Typing "zoom" with a tim.sleeptime.sleep(0.1)k.press('z')k.release('z')time.sleep(0.1)k.press('o')k.release('o')time.sleep(0.1)k.press('o')k.release('o')time.sleep(0.1)k.press('m')k.release('m')time.sleep(0.1)#Execute enter keyk.press(Key.enter)k.release(Key.enter)time.sleep(2)#Postion for mouse clickx=501y=291#Move mouse to positionpyautogui.moveTo(x, y, duration = 2)#Click on the positionpyautogui.click()#Enter Zoom credentialsk.type(ID)k.type(Pass)最后 2 行抛出错误:Traceback (most recent call last): File "C:/Users/rijul/Desktop/PyCharm Projects/learningclass.py", line 50, in k.type(ID) File "C:\ Users\rijul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pynput\keyboard_base.py", line 461, in type for i, character in enumerate(string): TypeError: 'int' 对象不可迭代PS 你需要安装 zoom 才能工作......
查看完整描述

3 回答

?
HUH函数

TA贡献1836条经验 获得超4个赞

更改最后两行

k.type(str(ID))
k.type(str(Pass))


查看完整回答
反对 回复 2023-04-18
?
人到中年有点甜

TA贡献1895条经验 获得超7个赞

ID = int(input('Enter ID: '))
Pass = int(input('Enter Pass: '))

变量将输入作为integersk.type需要的字符串。

解决这个问题的一种方法是使它成为一个字符串 -str(ID)


查看完整回答
反对 回复 2023-04-18
?
忽然笑

TA贡献1806条经验 获得超5个赞

我认为您传递了错误的参数,因为 k.type 正在寻找string价值,而您传递的是integer. 简而言之,您应该用IDandPass作为 astring代替integer.

ID = input('Enter ID: ')
Pass = input('Enter Pass: ')


查看完整回答
反对 回复 2023-04-18
  • 3 回答
  • 0 关注
  • 73 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信