hug2wisdom / learnpython

note the points of learn python
0 stars 0 forks source link

r #1

Open hug2wisdom opened 4 years ago

hug2wisdom commented 4 years ago

If you don’t want characters prefaced by \ to be interpreted as special characters, you can use raw strings by adding anr before the first quote:

print(r'C:\some\name')  # note the r before the quote
C:\some\name
hug2wisdom commented 4 years ago

The keyword argument end can be used to avoid the newline after the output, or end the output with a different string:

>>> a, b = 0, 1
>>> while a < 1000:
...     print(a, end=',')
...     a, b = b, a+b
...
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,