<human>:  How to truncate a string using str.format in Python?
<bot>: Here is some code to display first 5 characters of string 'aaabbbccc'

"""{:.5}""".format('aaabbbccc')

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.