M
M
Michael2019-02-25 11:45:21
Python
Michael, 2019-02-25 11:45:21

How to change the type of a variable in python?

Good afternoon,
Sending bash spript output data to zabbix server.
Bash script counts the number of lines in a file (wc -l).
The variable turns out to be a string variable, and zabbix treats it as text.
And I need the variable to be numeric in order to plot graphs on zabbix.
Python 2.7.7, how to change variable type to numeric output?
### Bash script run
p = subprocess.Popen("./test", stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
p_status = p.wait()
print "Command output : ", output
print "Command exit status/return code : ", p_status
subprocess.call(['/usr/bin/zabbix_sender', '-z', 'x/x/x/x', '-p', '10051', '

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
energizer888, 2019-02-25
@energizer888

your_int_variable = int(your_str_variable)

M
Mikhail, 2019-03-07
@ARMADIK

str(int(output)) - for some reason only this helped.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question