您的位置:首页 > 编程语言 > Python开发

python os.system() 支持中文路径名

2015-12-21 09:38 645 查看
需求: push 一个带中文路径名的文件到android  平台里。  如果filename 带中文名,需要执行下面的代码:<pre name="code" class="python">src_file_path.decode('utf8').encode('GBK') 才能成功
def push_file_to_platform(filename):# use adb ,may be  can use networksrc_file_path = filename.replace('\n','')tmp_src_file_path = src_file_path.decode('utf8').encode('GBK')print "pushing.............. %s to /sdcard/"%tmp_src_file_pathret = os.system(r'adb push "%s" /sdcard/'% tmp_src_file_path)if( ret !=0):print "pushing fail"return Falseelse:print r"pushing............. %s  /sdcard/ done"% tmp_src_file_pathreturn True
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: