-1

I use the MonkeyRunner tool which provides an API in order to manage an Android emulator or device through a script written in Python. I have assigned a process_id of an application using pid = device.shell('pidof [s] PACKAGE_NAME') command. When I concatenate the pid with another string and print the result, I get a string which has 2 lines. I need to remove the reason for breaking new line from the variable pid. How can I trim the result in order to get the raw data of pid?

Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
talha06
  • 6,206
  • 21
  • 92
  • 147

1 Answers1

1

Use the string method strip(). It will remove whitespace characters from either end of the string.

pid = device.shell('pidof [s] PACKAGE_NAME').strip()
BoarGules
  • 16,440
  • 2
  • 27
  • 44