super newbie question: escape character - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: super newbie question: escape character (/thread-31971.html) |
super newbie question: escape character - tsavoSG - Jan-13-2021 i'm trying pycharm and idle at the same time, and found a strange situation print("1 hello") print("2 hell\n o") [color=#E74C3C]print("3 hell\r xxx") print("4 hell\rxxx") print("5 hell\b o")[/color] print("6 hell\to")the result in pycharm: in idle: why are the difference in line 3, 4 & 5?
RE: super newbie question: escape character - bowlofred - Jan-13-2021 You have different terminal emulators that are probably dealing with the carriage return character \r differently. The program is sending the same characters to stdout, but the terminal rendering is acting on that information in a different way.The first is treating it as "go back to beginning of the line". So in that case the text afterward overwrites the text written earlier on that line. The second is treating it as a more normal end of line and not allowing it to overwrite the previous text. This looks like a program rendering issue, not a python programming issue. You'd have the same thing if you just had a file with that output as contents and had the programs try to display it. RE: super newbie question: escape character - tsavoSG - Jan-13-2021 well, this is all the code, it's something like my third day in Python world i'm starting from the very beginning. RE: super newbie question: escape character - tsavoSG - Jan-13-2021 (Jan-13-2021, 01:08 AM)bowlofred Wrote: You have different terminal emulators that are probably dealing with the carriage return character i'm reviewing different on-line videos for starters, and one is using the built-in IDLE, the other PyCharm. Thanks for the tips, as long as it's not a syntax problem, i'm ok. will worry about the setup later. Danks |