Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How can i limit length string?
#1
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.
Quote
#2
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.
Quote
#3
(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
Quote
#4
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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  python gives wrong string length and wrong character thienson30 2 290 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  Highlight/Underline a string | ValueError: zero length field name in format searching1 1 590 Jul-01-2019, 03:06 AM
Last Post: metulburr
  calculating length of string desul 12 4,062 May-22-2019, 10:50 AM
Last Post: ankit
  Python - Limit Sentence Length to 10 Words - Text file dj99 2 1,566 Jul-21-2018, 02:24 PM
Last Post: dj99
  Python find the minimum length of string to differentiate dictionary items zydjohn 3 1,175 Mar-03-2018, 05:23 PM
Last Post: Gribouillis
  Get string length RedSkeleton007 3 1,445 Dec-04-2017, 03:19 PM
Last Post: DeaD_EyE

Forum Jump:


Users browsing this thread: 1 Guest(s)