【问题标题】:Cyrillic text in MonkeyRunnerMonkeyRunner 中的西里尔文字
【发布时间】:2013-05-19 19:43:25
【问题描述】:

我正在尝试使用 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()显示西里尔字符的正确方法是什么?

【问题讨论】:

    标签: android python unicode monkeyrunner


    【解决方案1】:

    查看 ADBKeyBoard:https://github.com/senzhk/ADBKeyBoard

    device.shell("am 广播 -a ADB_INPUT_TEXT --es msg 'Серёжа'")

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-15
      • 1970-01-01
      • 2023-03-08
      相关资源
      最近更新 更多