A Brief discussion on the problem of os.path.join slash in python splicing path
- 2020-12-26 05:47:47
- OfStack
During debugging, a backslash was found on the path spliced through os.path.join
directory1='/opt/apps/upgradePackage'
directory2='icp_v1.8.0'
directory3=os.path.join(directory1,directory2)
print('directory3 : %s' %directory3)
The execution result
directory3 : /opt/apps/upgradePackage\icp_v1.8.0
Splicing symbol became "\", research along while, the discovery is the first directory behind the missing "/", plus "/", the program execution is correct.
directory1='/opt/apps/upgradePackage/'
The execution result
directory3 : /opt/apps/upgradePackage/icp_v1.8.0