用python寫個翻譯小指令碼

2021-08-28 08:21:07 字數 1171 閱讀 5862

想法:有的時候,想開始乙個專案,但是在給專案起乙個合適的英文名的時候突然被英語詞彙量攔住了,怎麼辦?那就開啟瀏覽器蒐個翻譯軟體查詢咯,但是這樣過程略顯繁瑣,想著自己寫個小指令碼,要用的時候直接命令列敲就行了。也不用再開啟乙個瀏覽器那麼多步驟了。說幹就幹。

設計

執行在命令列如這種形式: python3 translate.py 源 目的

運用的包使用方法:

python3 translate.py query result # 將query翻譯成result指定的語言.

python3 translate.py -h # 獲取幫助文件

源**:

import requests

import hashlib

import sys

def main():

"""param1:查詢字元,為自動判斷

param2:目的字元,可選引數有

zh:中文

en:英文

yue:粵語

wyw:文言文

"""# 檢視幫助文件

if sys.argv[1] == "-h":

print(main.__doc__)

else:

q = sys.argv[1]

from = "auto"

to = sys.argv[2]

salt = 15010110083

result_all = requests.get(url1).json()

result_dst = result_all["trans_result"][0]["dst"]

print(result_dst)

"""將一些列必備的引數拼接到一起,並進行md5加密"""

q = q

salt = salt

pwd = "wpxi4ftjeswik_qerzxw"

hash = hashlib.md5()

hash.update(str1.encode("utf-8"))

return hash.hexdigest()

if __name__ == '__main__':

main()

python小指令碼

匹配文件內容的關鍵字,並取得該關鍵字所在行所有內容 find the row where need keyword def getcontent tfile,sstr global keyword f1 open tfile readlines for i,j in enumerate f1 if ...

python檔案命名小指令碼

寫個檔案命名的python程式,復 yu 習一下python。程式寫得應該不是很好。import os import shutil from pil import image 輸入為路徑 命名方式為統一位數數字遞增 單一檔案格式查詢 輸出為 result.txt 檔名,是否為完整 full 完整庫 ...

Python版Mssql爆破小指令碼

mssql python版本爆破小指令碼,需要安裝 mssql python.exe 可以看出 量很少,用法 儲存 為mssqldatabawww.cppcns.comseblasting.py,cmd切換到 mssqldatabaseblasting.py路徑下,並 執行 mssqldatabas...