python2中文路径问题

 

test.py所在文件夹C:\Users\PC\Desktop\测试路径\test.py

#coding:utf-8

import logging
import os

#当前目录
currentpath=unicode(os.getcwd(),'gbk')
print currentpath #C:\Users\PC\Desktop\测试路径

#上一级目录
path=os.path.dirname(unicode(os.getcwd(),'gbk'))
print  path #C:\Users\PC\Desktop

#路径拼接
newpath=path+u"\说明.txt"

 

posted @ 2018-07-11 10:50  shine_pan  阅读(2232)  评论(0编辑  收藏  举报