[Tutor] Another prob with Telnet
Lloyd Kvam
pythonTutor at venix.com
Sat Aug 14 18:10:04 CEST 2004
On Sat, 2004-08-14 at 11:25, Ali Polatel wrote:
> I looked up the web-site
> http://www.robelle.com/library/smugbook/ascii.txt but couldn't
> understand anything :
> "LF 12 10 a ^J Line Feed"
LF short name for the character
12 value of character in octal
10 value of character in decimal
a value of character in hex
^J keystroke on keyboard (ctrl+j)
Line Feed long name for character.
The python builtin functions ord and chr are the most useful for dealing
with character values. chr takes an integer value and returns the
corresponding string character. ord takes a string character and
returns its integer value.
ord('\n') == 10
chr(10) == '\n'
The column of decimal values is generally the most useful when working
with ord and chr.
> What should I type in my programme script to make it work?
assume fp is your file type object
fp.write('\n') # should write a linefeed
fp.write(chr(10)) # should also write a linefeed
You may need to use
fp.flush()
to force your output out of the buffer.
> Regards,
>
>
>
> ______________________________________________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
>
> ______________________________________________________________________
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice: 603-653-8139
fax: 801-459-9582
More information about the Tutor
mailing list