python - 不打印减号
问题描述
我写的
pyautogui.typewrite(to_type)
为自动化键盘和鼠标编写脚本。to_type = -0.2,它只写 0.2。我有英文键盘。它不加减号为
pyautogui.typewrite(-0.2)
也是。你知道问题出在哪里吗?谢谢
代码
import pyautogui
import time
for i in range(1, 3):
pyautogui.click(509, 679) # move to field
pyautogui.typewrite(['backspace', 'backspace', 'backspace', 'backspace', 'backspace', 'backspace', 'backspace', 'backspace'])
value = -0.5 + (i - 1) * 0.3 # computation numbers that will be write in field
to_type = "%f" % value
print(to_type)
#pyautogui.press('-')
pyautogui.typewrite(to_type) # writing previous number
time.sleep(2)
pyautogui.typewrite(['enter']) # enter the input of number
pyautogui.PAUSE = 0.5
pyautogui.click(169, 681) # plot
pyautogui.PAUSE = 0.5
pyautogui.click(330, 685) # save
pyautogui.click(448, 174) # file name
to_type = "data{}".format(i)
print(to_type)
pyautogui.typewrite(to_type) # writing name of file
pyautogui.click(978, 664) # save file
pyautogui.PAUSE = 0.5
解决方案
typewrite
接受一个字符串,但你传递了一个浮点数。尝试这个:
pyautogui.typewrite("-0.2")
推荐阅读
- swift - 检查用户是否登录了firebase
- c++ - noexcept 说明符取决于模板类成员函数
- json - Powerapps 中的嵌套表 - 解析 JSON 时删除“值”列
- java - 为什么 Kotlin 进行空检查,当反编译为 Java 时会声明一些未使用的变量?
- java - ElGamal 阈值加密 - 非确定性解密问题
- android - 不允许使用cordova加载本地资源:file:///android_asset/www/
- javascript - MODULE 不起作用 - 未知突变类型:user/setUserInfo
- python - 在卷积神经网络中,如何使用 Maxout 而不是 ReLU 作为激活函数?
- flutter - 如何设置 CupertinoDatePicker 的位置?
- python - Django-Haystack 无法获取模板 .txt 文件中的数据