为什么print os.path.isdir(r'C:\Windows')括号中要加r?

慕粉064957747
浏览 1701回答 1
1回答

Nelson_Zhao

r代表匹配原始字符,在通配符中'\'需要进行转义,如果不加r,默认'\'为转义字符,此时还想达到原语句的效果,就需要写成print os.path.isdir('C:\\Windows')
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python