Python Forum

Full Version: How can i limit length string?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.
I'm not python developer, but i need change some python script.
I use this script in my zabbix-server for rabbitMQ
https://github.com/jasonmcintosh/rabbitm...tmq/api.py
And names on my rabbitMQ-server queues are long, more then 128 symbols and i can't write them to my database on zabbix-server.
So i need change the script for limit value queue['name'] to 128 symbols.
How can i change the script?
Please, help me
Thank you.
variable = queue['name'][:128]
will give you a string variable variable which is queue['name'] truncated to 128 first characters. If it is less it will still work fine.
(Feb-10-2020, 12:11 PM)Jendker Wrote: [ -> ]
variable = queue['name'][:128]
will give you a string variable variable which is queue['name'] truncated to 128 first characters. If it is less it will still work fine.

Thank you for the reply. It is working, but in which part my api.py file should i add this line?
I don't know.... Sad
Just replace queue['name'] everywhere with queue['name'][:128] and probably you will be fine.
Or even better: try to learn some Python, it is not that difficult Smile