简体   繁体   中英

What does `print` interprete as whitespace?

What is the complete list of whitespace characters that print interprets as such?

I need to truly understand how the print statement works in Python. So far so weird, but this is one detail that I can't figure out:

In Python's reference manual chapter 6.6 it says:

... when the last character written to standard output is a whitespace character except ' ', ...

I know that the most common whitespace for this case is '\\n', but I need to know the others.

In CPython, it is probably all characters for which isspace() returns true , namely:

  • \\f (form feed)
  • \\n (linefeed)
  • \\r (carriage return)
  • \\t (horizontal tab)
  • \\v (vertical tab)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM