0x00 问题
1、路径空格
在使用python调用cmd指令时,遇到路径中包含空格,会出现路径找不到的问题。
2、在python调用cmd指令时,若出现中文时,出现乱码问题。
0x02 解决
1、添加双引号(注意转义)
例如,F:\temp\test test,当在F盘根目录调用指令dir F:\temp\test test,报错找不到路径
import os
os.system(“dir F:\temp\test test”)
添加单引号,不能解决问题,需添加双引号
import os
os.system(“dir “F:\temp\test test””)
2、中文乱码
系统默认是GBK,需pycharm与系统匹配
将project encoding改为:GBK