乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      純自動化的消息發(fā)送工具實(shí)現(xiàn)!

       Python集中營 2022-12-04 發(fā)布于甘肅

      純自動化的python實(shí)現(xiàn)模仿的是人的手動操作的過程,并不做后端接口等的實(shí)際操作。

      通過模仿手動操作完成業(yè)務(wù)處理,這里使用到了兩個python的非標(biāo)準(zhǔn)模塊,分別是pyautogui和pyperclip模塊。

      如果沒有安裝的話直接使用pip的方式安裝一下這兩個模塊。

      pip install pyperclip -i https://pypi.tuna./simple

      pip install pyautogui -i https://pypi.tuna./simple

      安裝過程沒有其他比較曲折的操作,安裝完成后將我們需要的模塊導(dǎo)入到代碼塊中即可。

      # Importing the pyautogui module and renaming it to gui.
      import pyautogui as gui

      # Importing the pyperclip module and renaming it to clip.
      import pyperclip as clip

      # Importing the time module and renaming it to t.
      import time as t

      本文代碼塊中的部分注釋是使用AI插件自動生成的,省去了我開發(fā)代碼塊時編寫注釋的過程。

      由于實(shí)現(xiàn)過程比較簡單這里并沒有編寫對象類,直接在.py的文件中創(chuàng)建一個send_message()函數(shù)。

      def send_message(fri_name=None, msgs=None):
          """
          This function sends a message to a friend.

          :param fri_name: The name of the friend you want to send the message to
          :param msgs: The message you want to send
          """

          gui.hotkey('ctrl''alt''w')
          gui.hotkey('ctrl''f')
          gui.copy(fri_name)
          gui.hotkey('ctrl''v')
          t.sleep(0.5)
          gui.press('enter')
          # 通過使用一系列的快捷鍵的操作,這個時候需要發(fā)消息的用戶聊天窗口已經(jīng)打開了
          for msg in msgs:
              clip.copy(msg)
              clip.hotkey('ctrl''v')
              clip.press('enter')
              t.sleep(1)

      這個時候通過一系列的模仿手動打開微信和復(fù)制粘貼的動作以及使用enter鍵發(fā)送消息等,一系列動作就操作完了。

      因?yàn)閏trl+alt+w的快捷鍵是打開微信,我們也可以替換成打開其他應(yīng)用的快捷鍵,比如說QQ等。

      最后,只需要傳入朋友昵稱參數(shù)和需要發(fā)送的消息列表就能實(shí)現(xiàn)自動化發(fā)消息的操作了。

      send_message(fri_name='張三', msgs=['消息1''消息2''消息3''消息4''消息5''消息6''消息7'])

      「Python 集中營」,只做知識分享 !

      只需十幾行代碼,輕松爬取公眾號文章!

      介紹幾個常用的搜索引擎語法,查找資料如虎添翼!

      手撕一個圖片色卡提取器,可自定義提取色卡數(shù)量!

      分享幾個python比較炫酷的3D效果圖代碼塊開發(fā)過程!

        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多