Код: Выделить всё
def convert(str) :
bcount = 0
ecount = len(str) -1
while bcount < len(str) :
if str[bcount] != " " and str[bcount] != "\t" and str[bcount] != "\n" :
break
bcount += 1
while ecount > bcount :
if str[ecount] != " " and str[ecount] != "\t" and str[ecount] != "\n" :
break
ecount -= 1
if ecount +1 > 32 :
return str[bcount:32]
else :
return str[bcount:ecount +1]Кто не знает Питон, но знает С++, поясню, что эта функция отрезает строку, окруженную пробелами, табами, или символом перевода строки. То есть была строка например
Код: Выделить всё
# Hello, World! #Код: Выделить всё
#Hello, World!#