Python 3中的反斜杠
我两三天前才开始学蟒蛇3,所以我是个十足的笨蛋。我从一本叫《如何像计算机科学家一样思考》的书中学习,它使用了蟒蛇2而不是蟒蛇3。。。当它告诉我反斜杠字符时我被卡住了。。。我在网上找不到任何东西Python 3中的反斜杠,python,python-3.x,backslash,Python,Python 3.x,Backslash,我两三天前才开始学蟒蛇3,所以我是个十足的笨蛋。我从一本叫《如何像计算机科学家一样思考》的书中学习,它使用了蟒蛇2而不是蟒蛇3。。。当它告诉我反斜杠字符时我被卡住了。。。我在网上找不到任何东西 print("This is a test /n This is a test") 书上说我应该得到这样的东西: This is a test This is a test 但我得到的是: This is a test /n This is a test 我做错什么了吗?反斜杠是另一个斜杠,\: &
print("This is a test /n This is a test")
书上说我应该得到这样的东西:
This is a test
This is a test
但我得到的是:
This is a test /n This is a test
我做错什么了吗?反斜杠是另一个斜杠,
\
:
>>> print('This is a test \n This is a test')
This is a test
This is a test
您使用的是正斜杠,/
另见:
反斜杠字符\
(不要与斜杠/
混淆)
您使用的是正斜杠
/
,而不是反斜杠\
print("This is a test \n This is a test")
This is a test
This is a test