06、迷你 Stackoverflow
作为一名程序员,我知道我们每天都需要 StackOverflow,但你不再需要在 Google 上搜索它。现在,在您继续处理项目的同时,在你的 CMD 中获得直接解决方案。通过使用 Howdoi 模块,你可以在命令提示符或终端中获得 StackOverflow 解决方案。你可以在下面找到一些可以尝试的示例。
# Automate Stackoverflow
# pip install howdoi
# Get Answers in CMD
#example 1
> howdoi how do i install python3
# example 2
> howdoi selenium Enter keys
# example 3
> howdoi how to install modules
# example 4
> howdoi Parse html with python
# example 5
> howdoi int not iterable error
# example 6
> howdoi how to parse pdf with python
# example 7
> howdoi Sort list in python
# example 8
> howdoi merge two lists in python
# example 9
>howdoi get last element in list python
# example 10
> howdoi fast way to sort list
07、自动化手机
此自动化脚本将帮助你使用 Python 中的 Android 调试桥 (ADB) 自动化你的智能手机。下面我将展示如何自动执行常见任务,例如滑动手势、呼叫、发送短信等等。您可以了解有关 ADB 的更多信息,并探索更多令人兴奋的方法来实现手机自动化,让您的生活更轻松。
# Automate Mobile Phones
# pip install opencv-python
import subprocess
def main_adb(cm):
p = subprocess.Popen(cm.split(' '), stdout=subprocess.PIPE, shell=True)
(output, _) = p.communicate()
return output.decode('utf-8')
# Swipe
def swipe(x1, y1, x2, y2, duration):
cmd = 'adb shell input swipe {} {} {} {} {}'.format(x1, y1, x2, y2, duration)
return main_adb(cmd)
# Tap or Clicking
def tap(x, y):
cmd = 'adb shell input tap {} {}'.format(x, y)
return main_adb(cmd)
# Make a Call
def make_call(number):
cmd = f"adb shell am start -a android.intent.action.CALL -d tel:{number}"
return main_adb(cmd)
# Send SMS
def send_sms(number, message):
cmd = 'adb shell am start -a android.intent.action.SENDTO -d sms:{} --es sms_body "{}"'.format(number, message)
return main_adb(cmd)
# Download File From Mobile to PC
def download_file(file_name):
cmd = 'adb pull /sdcard/{}'.format(file_name)
return main_adb(cmd)
# Take a screenshot
def screenshot():
cmd = 'adb shell screencap -p'
return main_adb(cmd)
# Power On and Off
def power_off():
cmd = '"adb shell input keyevent 26"'
return main_adb(cmd)