0

I am new to python. Need help to solve below issue.

Using robot framework with python. Postgres DB is deployed on different machine. And I have accessed it using SSHLibrary.

imei_list = obj.executePostgresQueryToGetResult(db_name='XXXXXX', query=select_query_to_get_result)
print "type: ", type(imei_list)
print "lst: ", "\"" +imei_list+ "\""

When select command is executed, output is returned in String type as below:

type:  <type 'str'>
lst:  "
 359750090003937
 359750090003275
 359750090004513
 359750090003804
 359750090003267
 359750090003226
 359750090001865
"

Need to format output as below is String type:

"359750090003937", "359750090003275", "359750090004513", "359750090003804","359750090003267", "359750090003226", "359750090001865"

NOTE: Numbers returned by query may vary.

1 Answer 1

2

You can do

imei_list = imei_list.split("\n")

in order to get a list from your string. Afterwards just join the list again

out_string = "\"" + "\", \"".join(imei_list) + "\""

which should give you the desired result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.