我正在尝试使用 MonkeyRunner 在我的 Android 设备上输入西里尔文字,但它要么不输出任何内容,要么只输出问号(“?”)字符。
代码:
print (sys.getdefaultencoding())
print (locale.getpreferredencoding())
print (sys.stdout.encoding)
提供以下输出:
ascii
None
Cp1251
我尝试了以下方法来显示文本:
device.type('Мой текст') #This code type nothing
device.type(u'Мой текст') #This code type nothing
device.type(unicode('Мой текст','cp1251')) #This code type nothing
device.type(unicode('Мой текст','cp1251').encode('utf8')) #This code type nothing
device.type(u"\u0410".encode('utf8')) #This code type ??
device.type("\xe2\x98\x83".decode('utf8')) #This code type ?
使用编码/解码方法或任何其他方式通过 device.type()
显示西里尔字符的正确方法是什么?
最佳答案
参见 ADBKeyBoard:https://github.com/senzhk/ADBKeyBoard
device.shell("am broadcast -a ADB_INPUT_TEXT --es msg 'Серёжа'")
关于android - MonkeyRunner 中的西里尔文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16731019/