![]() Our goal is to print them in a single line and use some special parameters to the print function to achieve that. So when we have multiple print statements the output from each of them is printed in multiple lines as you can see in the example below. There is an answer below that is functional overall. In python the print statement adds a new line character by default. It affects file output and some other miscellaneous things that have nothig to do with it. Maybe someone can point me to a functional way to do this? Thanks.įor those suggesting the environment buffering fixes it, it does not. I can't find anyway to do this with print in Python 2.7. ![]() I would much prefer to be able to output the first print string to the console, execute other code, and then put in the part with the newline. The line gets printed, but it's all printed at once, meaning that it is buffered until it gets the print with the newline character in it. This is not ideal as if I print a line, such as: print("We're doing something.",end='')Īnd then follow that with any other code, and then a line such as: print("we finished doing that thing.") My current implementation involves importing the Python 3 print function from the future library, and using end=''. I have a need in Python 2.7 to print text to the console without newline characters, so I can continue writing more text on that same line later with future code.
0 Comments
Leave a Reply. |