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')

原文地址:https://www.cnblogs.com/amize/p/14296325.html