如何在python中包含“enter key”

2024-05-09 08:34:38 发布

您现在位置:Python中文网/ 问答频道 /正文

import subprocess

path = '/home/test/net.keystore

text = subprocess.Popen(['keytool', '-list', '-v', '-keystore', path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
file = text.stdout.read().decode().splitlines()
print file

through subprocess i trying to fetch keystore certificate details I don't know password for keystore. If i press "enter key" twice then output is processing

Is there any way to automate "Enter key" in python?


Tags: topathkeytexttestimporthomenet
2条回答

这个安装过程对我有效: C: \Python3>;pip.exe安装键盘

`导入键盘

键盘。按'u和'u release('enter')`

我在Win10上用过,简单的按下('enter')就关闭了活动按钮,但是按下并释放有效。

您可以使用keyboard模块,可以使用pip和命令python -m pip install keyboard安装该模块。

以下代码将按回车键:

from keyboard import press
press('enter')

相关问题 更多 >