python - Pad outgoing messages -
i can't quite figure out how pad message send. basically.. want pad message max 512 chars defined in rfc.
i understand message being sent user contain user!user@hostname privmsg #chan (or other_user): text text text \r\n.
thanks in advance.
to pad string can use functions ljust
, center
or rjust
, respectively:
print "hello, " + "world".ljust(10) + "!" print "hello, " + "world".center(10) + "!" print "hello, " + "world".rjust(10) + "!"
output (try it):
hello, world ! hello, world ! hello, world!
all 3 functions have optional second argument fillchar
lets specify character used fill additional space.
Comments
Post a Comment