SoFunction
Updated on 2024-11-18

Using Python to read the screen resolution of the Android phone method

Using Python to read the screen resolution of the Android phone method

Updated March 31, 2018 10:50:29 by KitStar
The following editorial will share a method to read the screen resolution of Android phone using Python, which has a good reference value and hopefully will be helpful to you. Together follow the editor over to see it

Direct code it:

import os
import sys
import json
import re
def _get_screen_size():
 'Get phone screen size'
 size_str = ('adb shell wm size').read()
 if not size_str:
  print('Please install ADB and drivers and configure environment variables')
  ()
 m = (r'(\d+)x(\d+)', size_str)
 if m:
  return "{height}x{width}".format(height=(2), width=(1))
 return "1920x1080"

The above method of using Python to read the screen resolution of an Android phone is all I have to share with you, I hope it will give you a reference, and I hope you will support me more.

  • python
  • retrieve
  • screen (TV, computer or movie)
  • resolution (of a photo)

Related articles

  • Python implementation of reading a large number of Excel files and cross-file batch average calculation

    This article is mainly for you to introduce in detail how to use the Python language, the realization of a number of different Excel files to read the data and the average value of the calculation method, interested you can learn about it!
    2023-02-02
  • Python implementation of the script lock function (only one script can be executed at the same time)

    This article focuses on the implementation of Python script lock function (only one script can be executed at the same time), this article shares two methods, you can choose the method that suits you according to personal needs
    2017-05-05
  • :1366 Error resolution

    through python to synchronize the data to the mysql database process, encountered errors, this article focuses on: 1366 error resolution, with some reference value, interested in can learn about it
    2024-05-05
  • Input and output of the embedded gradio application on the website to do the audit implementation details

    This article mainly for you to introduce the website embedded gradio application of input and output to do the audit to achieve details, there is a need for friends can refer to reference, I hope to be able to help, I wish you more progress, an early promotion and salary increase!
    2023-04-04
  • python+selenium realize resume auto-refresh sample code

    This article introduces the python + selenium resume automatically refreshes the sample code, the text through the sample code is very detailed, for everyone's learning or work has a certain reference value of learning, the need for friends below with the editorial to learn together!
    2019-05-05
  • A problem encountered with go and python variable assignment

    This article introduces the go and python variable assignment encountered a problem related information, need friends can refer to the following
    2017-08-08
  • Based on the analysis of graph module graph structure in TensorBoard

    Today, I'd like to share with you an article based on the analysis of graph module graph structure in TensorBoard, with good reference value, I hope it will be helpful to you. Together follow the editor over to see it
    2020-02-02
  • Sample code for TensorFLow math operations

    This article introduces the TensorFLow mathematical operations sample code, the text of the sample code through the introduction of the very detailed, for everyone to learn or work with a certain reference to the learning value of friends who need the following with the editorial to learn together!
    2020-04-04
  • Example of a Python implementation that confirms whether a string contains the specified string or not

    Below I'll share with you an example of Python implementation to confirm whether the string contains the specified string, with good reference value, I hope it will help you. Together follow the editor over to see it
    2018-05-05
  • Python tornado queue example - a concurrent web crawler code sharing

    This article introduces the Python tornado queue example - a concurrent web crawler code to share, with some reference value, the need for friends can refer to the following
    2018-01-01

Latest Comments