• limit text length in Python

    Answered

    limit text length in Python? orĀ  truncate a long string in python?

    Silver Member Asked on June 12, 2018 in Python.
    Add Comment
  • 1 Answer(s)
    Best answer

     

    var data="sadddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
    
    var info = (data.length > 75) ? data.substring[0,75] + '..' : data;
    ---------------------------OR--------------------
    info = (data[:75] + '..') if len(data) > 75 else data
    

     

    Silver Member Answered on June 12, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.