1、会导致程序打印false错误的代码如下:
1 # -*- coding:utf-8 -*- 2 import os 3 import sys 4 from uiautomator import device as d 5 6 filepath = r'E:ProjectA3A_8_4Gexerciseapp_list你好.apk' 7 8 if os.path.isfile(filepath): 9 print "true" 10 else: 11 print "false"
2、将文件名称由中文改为英文,在pycharm中就返回true了
1 # -*- coding:utf-8 -*- 2 import os 3 import sys 4 from uiautomator import device as d 5 6 filepath = r'E:ProjectA3A_8_4Gexerciseapp_listhello.apk' 7 8 if os.path.isfile(filepath): 9 print "true" 10 else: 11 print "false"
难道是pycharm中还有哪里需要设置吗,我将第一段的程序在python的编辑器中运行就运行正常,说明这个问题是由于pycharm中引出的,但具体是什么原因,望有知情人士帮忙解答,万分感谢
以上遇到的问题通过下面这个贴子还是没能彻底解决掉:https://blog.csdn.net/zhonggaorong/article/details/53814215
但我在程序中再加一行进行转下码,奇迹发生运行正常了,如下图例子中第7行
1 # -*- coding:utf-8 -*- 2 import os 3 import sys 4 from uiautomator import device as d 5 6 filepath = r'E:ProjectA3A_8_4Gexerciseapp_list你好.apk' 7 uipath = unicode(filepath,"utf8") 8 9 if os.path.isfile(uipath): 10 print "true" 11 else: 12 print "false"
运行正常