将os.system的输出保存到文本文件

将os.system的输出保存到文本文件,第1张

将os.system的输出保存到文本文件

请尝试以下 *** 作

import os import subprocess import timeprint ('Current Directory: {}'.format(os.getcwd()) ) print ('Opening Android SDK...') os.chdir('C:\android-sdk\platform-tools') print ('Current Directory: {}'.format(os.getcwd()) )t = str(time.ctime()) try:    process_output = subprocess.check_output(["adb", "devices", "-l"])except: #Add here the type of exception you want to raise and logic    print("Please check your ADB installation and syntax.")s = ('{} Checking for connected devices: {}'.format(t,process_output) ) with open('logfile.txt', 'w') as f:    f.write(s)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5645129.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存