新手换行符问题
Python 3.8.5 (default, Sep3 2020, 21:29:08) :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information.
>>> str1 = 'c:\now'
>>> str1
'c:\now'
>>> str1 = 'c:\\now'
>>> str1
'c:\\now'
>>> str1 = r'c:\\now'
>>> str1
'c:\\\\now'
>>>
这是怎么回事,python太智能了默认自动跟我加了转义符,怎么才弄的跟教材一样,我自己来手动加转义符。
python并没有给你自动加转义符,而是你输入的字符串内容本来就是那个,str1 = 'c:\now',你想知道str1是什么当然也是'c:\now'了,要想看效果你得print
页:
[1]