python打开文件,路径存在'\t'被转义

文章目录

      • 路径被转义
    • 修改

路径被转义

srcFile='E:\company\BMCC\日常报告\APT\top20\top20正式版\12月\告警IP列表Top20-1212.xlsx'
    dstFile='E:\company\BMCC\日常报告\APT\top20\top20正式版\12月\告警IP列表Top20'+date+'.xlsx'

报错如下

C:\Python37\python.exe E:/programmer/code/python/AutomateTheBoringStuff/Document/top20/TOP20.py
E:\company\BMCC\日常报告\APT	op20	op20正式版
月\告警IP列表Top20-1212.xlsx not exists!

Process finished with exit code 0

修改

将路径中的\改成 两个\

srcFile='E:\company\BMCC\日常报告\APT\\top20\\top20正式版\\12月\告警IP列表Top20-1212.xlsx'
dstFile='E:\company\BMCC\日常报告\APT\\top20\\top20正式版\\12月\告警IP列表Top20'+date+'.xlsx'

你可能感兴趣的:(#,python基础)