python windows 路径写法

  1. 以下写法都可以

file = r'C:\config.yaml'
file = 'C:\config.yaml'

file = 'C:\\config.yaml'
file = r'C:\\config.yaml'

file = r'C:/config_auto_ui.yaml'
file = 'C:/config_auto_ui.yaml'

file = os.path.join('c:\','config.yaml')   # 这样写不行
file = os.path.join('c:\\','config.yaml')
file = os.path.join('c:/','config.yaml')

posted @ 2021-01-19 09:38  该显示昵称已被使用了  阅读(1913)  评论(0编辑  收藏  举报