本实验用pyqt5做了一个小软件,里面使用了市面上主流的6种翻译软件接口:谷歌、百度、有道、金山词霸、腾讯、必应,界面如图所示:

以下是程序代码:

import time,sys,os,hashlib,json,re
import requests,execjs,random,js2py
from PyQt5 import QtWidgets,sip
from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QLineEdit,QPushButton,QGridLayout
from PyQt5.QtGui import *
import urllib.request
import urllib.parse
import PyQt5
#检验是否含有中文字符
def language(strs):
for char in strs:
if (u'\u4e00' <= char and char <= u'\u9fff'):
return 'zh','en'#含有中文
return 'en','zh'#不含有中文 class Baidu():
def __init__(self):
self.url = 'https://fanyi.baidu.com/v2transapi?from=zh&to=en'
self.header = {
'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
'origin': 'https://fanyi.baidu.com',
'referer': 'https://fanyi.baidu.com/?aldtype=16047',
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
'x-requested-with': 'XMLHttpRequest',
'cookie': 'BIDUPSID=D3290C65C03AEF0E98D97B8641DFFB15; PSTM=1570785944; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; BAIDUID=0CC6F13854E81A68D3C564D36E7C8A03:FG=1; APPGUIDE_8_2_2=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BDSFRCVID=wt_OJeC626EDLgju-c_JbHce7gSxbKcTH6aoxbIy4_AgXmAxrp74EG0PJf8g0Ku-dWitogKKBmOTHg-F_2uxOjjg8UtVJeC6EG0Ptf8g0M5; H_BDCLCKID_SF=JJkO_D_atKvjDbTnMITHh-F-5fIX5-RLf5TuLPOF5lOTJh0RbtOkjnQD-UL82bT2fRcQ0tJLb4DaStJbLjbke6cbDa_fJ5Fs-I5O0R4854QqqR5R5bOq-PvHhxoJqbbJX2OZ0l8KtDQpshRTMR_V-p4p-472K6bML5baabOmWIQHDPnPyJuMBU_sWMcChnjjJbn4KKJxWJLWeIJo5Dcf3PF3hUJiBMjLBan7056IXKohJh7FM4tW3J0ZyxomtfQxtNRJ0DnjtpChbRO4-TF-D5jXeMK; delPer=0; PSINO=2; H_PS_PSSID=1435_21104_18560_26350; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1580216234,1580216243,1580458514,1580458537; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1580458539; __yjsv5_shitong=1.0_7_ed303110bee0e644d4985049ba8a5cd1f28d_300_1580458537306_120.10.109.208_66a3b40c; yjs_js_security_passport=630340c0505f771135167fa6df3e5215699dcf0b_1580458538_js; to_lang_often=%5B%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%2C%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%5D; from_lang_often=%5B%7B%22value%22%3A%22vie%22%2C%22text%22%3A%22%u8D8A%u5357%u8BED%22%7D%2C%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%2C%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%5D'
}
self.data = None
def get_sign_ctx(self):
ctx = execjs.compile(
r""" function n(r, o) {
for (var t = 0; t < o.length - 2; t += 3) {
var a = o.charAt(t + 2);
a = a >= "a" ? a.charCodeAt(0) - 87 : Number(a),
a = "+" === o.charAt(t + 1) ? r >>> a : r << a,
r = "+" === o.charAt(t) ? r + a & 4294967295 : r ^ a
}
return r
} function e(r) {
var o = r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g);
if (null === o) {
var t = r.length;
t > 30 && (r = "" + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr(-10, 10))
} else {
for (var e = r.split(/[\uD800-\uDBFF][\uDC00-\uDFFF]/), C = 0, h = e.length, f = []; h > C; C++)
"" !== e[C] && f.push.apply(f, a(e[C].split(""))),
C !== h - 1 && f.push(o[C]);
var g = f.length;
g > 30 && (r = f.slice(0, 10).join("") + f.slice(Math.floor(g / 2) - 5, Math.floor(g / 2) + 5).join("") + f.slice(-10).join(""))
}
var u = void 0
, l = "" + String.fromCharCode(103) + String.fromCharCode(116) + String.fromCharCode(107);
u =' """ + str(self.get_gtk()) + r""" ';
for (var d = u.split("."), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) {
var A = r.charCodeAt(v);
128 > A ? S[c++] = A : (2048 > A ? S[c++] = A >> 6 | 192 : (55296 === (64512 & A) && v + 1 < r.length && 56320 === (64512 & r.charCodeAt(v + 1)) ? (A = 65536 + ((1023 & A) << 10) + (1023 & r.charCodeAt(++v)),
S[c++] = A >> 18 | 240,
S[c++] = A >> 12 & 63 | 128) : S[c++] = A >> 12 | 224,
S[c++] = A >> 6 & 63 | 128),
S[c++] = 63 & A | 128)
}
for (var p = m, F = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(97) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(54)), D = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(51) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(98)) + ("" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(102)), b = 0; b < S.length; b++)
p += S[b],
p = n(p, F);
return p = n(p, D),
p ^= s,
0 > p && (p = (2147483647 & p) + 2147483648),
p %= 1e6,
p.toString() + "." + (p ^ m)
}
"""
)
return ctx
def get_sign(self, text):
ctx = self.get_sign_ctx()
sign = ctx.call("e", text)
# print(sign)
return sign
def get_token(self):
s = requests.session()
url = 'https://fanyi.baidu.com/'
html = requests.get(url, headers=self.header)
html = html.text
# print(html)
raw_tk_str = str(re.search('token:.*,', html))
token = raw_tk_str.split('\'')[1]
# print(token)
return token
def get_cookie(self):
import urllib.request
import http.cookiejar
cookie = http.cookiejar.CookieJar()
handler = urllib.request.HTTPCookieProcessor(cookie)
opener = urllib.request.build_opener(handler)
response = opener.open('https://fanyi.baidu.com/?aldtype=16047#zh/en/aa%E9%80%9F%E5%BA%A6')
# print(response)
for item in cookie:
print('%s = %s' % (item.name, item.value))
def get_gtk(self):
url = 'https://fanyi.baidu.com/'
html = requests.get(url)
html = html.text
raw_gtk_str = str(re.search('window.gtk = .*;', html))
gtk = raw_gtk_str.split('\'')[1]
# print('gtk '+gtk)
return gtk
def get_data(self, text,from_lan, to_lan):
data = {}
data['from'] = from_lan
data['to'] = to_lan
data['query'] = text
data['simple_means_flag'] = 3
data['transtype'] = 'realtime'
data['sign'] = self.get_sign(text)
data['token'] = self.get_token()
return data
def translate(self, text, from_lan, to_lan):
try:
self.data = self.get_data(text, from_lan, to_lan)
response = requests.post(self.url, headers=self.header, data=self.data)
#print('百度翻译结果为:',response.json()['trans_result']['data'][0]['dst'])
return response.json()['trans_result']['data'][0]['dst']
except:
return '程序出现了一点小问题,无法翻译' class Bing():
def __init__(self):
self.url = "http://api.microsofttranslator.com/v2/ajax.svc/TranslateArray2?"
def translate(self,content,from_lan, to_lan):
try:
data = {}
data['from'] = '"' + from_lan + '"'
data['to'] = '"' + to_lan + '"'
data['texts'] = '["'
data['texts'] += content
data['texts'] += '"]'
data['options'] = "{}"
data['oncomplete'] = 'onComplete_3'
data['onerror'] = 'onError_3'
data['_'] = '1430745999189'
data = urllib.parse.urlencode(data).encode('utf-8')
strUrl = self.url + data.decode() + "&appId=%223DAEE5B978BA031557E739EE1E2A68CB1FAD5909%22"
response = urllib.request.urlopen(strUrl)
str_data = response.read().decode('utf-8')
#print(str_data)
tmp, str_data = str_data.split('"TranslatedText":')
translate_data = str_data[1:str_data.find('"', 1)]
#print('必应翻译结果为:',translate_data)
return translate_data
except:
return '程序出现了一点小问题,无法翻译' class Ciba():
def __init__(self, word,lan,tolan):
self.word = word
self.url = 'http://fy.iciba.com/ajax.php?a=fy'
self.headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'
}
# 构造post请求的参数
self.post_data = {
'f': lan,
't': tolan,
'w': self.word
}
# 发送请求
def request_post(self):
res = requests.post(url=self.url, headers=self.headers, data=self.post_data)
# print(res.content.decode())
return res.content.decode()
# 解析数据
@staticmethod
def parse_data(data):
dict_data = json.loads(data)
if 'out' in dict_data['content']:
return dict_data['content']['out']
elif 'word_mean' in dict_data['content']:
return dict_data['content']['word_mean']
def translate(self):
data = self.request_post()
try:
#print('词霸翻译结果为:',self.parse_data(data))
return self.parse_data(data)
except:
return '程序出现了一点小问题,无法翻译' class Youdao():
def translate(self,content,lan,tolan):
try:
# 解决反爬机制
u = 'fanyideskweb'
d = content
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
f = str(int(time.time()*1000) + random.randint(1,10)) # 时间戳
c= 'rY0D^0\'nM0}g5Mm1z%1G4'
sign = hashlib.md5((u + d + f + c).encode('utf-8')).hexdigest() # md5加密,生成一个随机数
head={}
head['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
data = {}
# data 有道翻译数据表单
data['i'] = content
data['from'] = lan#'AUTO'
data['to'] = tolan#'AUTO'
data['smartresult'] = 'dict'
data['client'] = 'fanyideskweb'
data['salt'] = f # salt 与 sign 反爬机制 ,每次都会变化 salt就是时间戳
data['sign'] = sign # 使用的是u + d + f + c的md5的值。
data['ts'] = '1551506287219'
data['bv'] = '97ba7c7fb78632ae9b11dcf6be726aee'
data['doctype'] = 'json'
data['version'] = '2.1'
data['keyfrom'] = 'fanyi.web'
data['action'] = 'FY_BY_REALTIME'
data['typoResult'] = 'False'
data = urllib.parse.urlencode(data).encode('utf-8')
request = urllib.request.Request(url=url,data=data,headers=head, method='POST')
response = urllib.request.urlopen(request)
line = json.load(response) # 将得到的字符串转换成json格式
text=''
for x in line['translateResult']:
text += x[0]['tgt']
#print('有道翻译结果为:',text)
return text
except:
return '程序出现了一点小问题,无法翻译' class Google():
def __init__(self):
self.ctx = execjs.compile("""
function TL(a) {
var k = "";
var b = 406644;
var b1 = 3293161072; var jd = ".";
var $b = "+-a^+6";
var Zb = "+-3^+b+-f"; for (var e = [], f = 0, g = 0; g < a.length; g++) {
var m = a.charCodeAt(g);
128 > m ? e[f++] = m : (2048 > m ? e[f++] = m >> 6 | 192 : (55296 == (m & 64512) && g + 1 < a.length && 56320 == (a.charCodeAt(g + 1) & 64512) ? (m = 65536 + ((m & 1023) << 10) + (a.charCodeAt(++g) & 1023),
e[f++] = m >> 18 | 240,
e[f++] = m >> 12 & 63 | 128) : e[f++] = m >> 12 | 224,
e[f++] = m >> 6 & 63 | 128),
e[f++] = m & 63 | 128)
}
a = b;
for (f = 0; f < e.length; f++) a += e[f],
a = RL(a, $b);
a = RL(a, Zb);
a ^= b1 || 0;
0 > a && (a = (a & 2147483647) + 2147483648);
a %= 1E6;
return a.toString() + jd + (a ^ b)
}; function RL(a, b) {
var t = "a";
var Yb = "+";
for (var c = 0; c < b.length - 2; c += 3) {
var d = b.charAt(c + 2),
d = d >= t ? d.charCodeAt(0) - 87 : Number(d),
d = b.charAt(c + 1) == Yb ? a >>> d: a << d;
a = b.charAt(c) == Yb ? a + d & 4294967295 : a ^ d
}
return a
}
""")
def getTk(self,text):
return self.ctx.call("TL",text)
def translate(self,content,lan,tolan):
tk = self.getTk(content)
try:
if len(content) > 4891:
print("翻译的长度超过限制!!!")
return
param = {'tk': tk, 'q': content}
# 英译中url
if(lan == 'en'):
result = requests.get("""http://translate.google.cn/translate_a/single?client=t&sl=en
&tl=zh-CN&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss
&dt=t&ie=UTF-8&oe=UTF-8&clearbtn=1&otf=1&pc=1&srcrom=0&ssel=0&tsel=0&kc=2""",params=param)
# 中译英url
else:
result = requests.get("""https://translate.google.cn/translate_a/single?client=webapp
&sl=zh-CN&tl=en&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca
&dt=rw&dt=rm&dt=ss&dt=t&swap=1&otf=2&ssel=5&tsel=5&kc=1&""", params=param)
# print(result.json())
text=''
data=result.json()[0]
for vlue in data:
if not vlue[0] is None:
text+=vlue[0]
#print('谷歌翻译结果为:',text)
return text
except :
return '程序出现了一点小问题,无法翻译' class Tencent():
def __init__(self):
self.api_url = 'https://fanyi.qq.com/api/translate'
self.headers = {
'Cookie': 'fy_guid=605ead81-f210-47eb-bd80-ac6ae5e7a2d8; '
'qtv=ed286a053ae88763; '
'qtk=wfMmjh3k/7Sr2xVNg/LtITgPRlnvGWBzP9a4FN0dn9PE7L5jDYiYJnW03MJLRUGHEFNCRhTfrp/V+wUj0dun1KkKNUUmS86A/wGVf6ydzhwboelTOs0hfHuF0ndtSoX+N3486tUMlm62VU4i856mqw==; ',
'Host': 'fanyi.qq.com',
'Origin': 'https://fanyi.qq.com',
'Referer': 'https://fanyi.qq.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, '
'like Gecko) Chrome/73.0.3683.86 Safari/537.36', }
self.fromlang = 'auto'
self.text=''
self.tolang = 'en' # 设置默认为英语
self.sessionUuid = str(int(time.time() * 1000))
self.fy_guid, self.qtv, self.qtk = self.get_qtv_qtk()
self.headers['Cookie'] = self.headers['Cookie'].replace(
'605ead81-f210-47eb-bd80-ac6ae5e7a2d8', self.fy_guid)
self.headers['Cookie'] = self.headers['Cookie'].replace(
'ed286a053ae88763', self.qtv)
self.headers['Cookie'] = self.headers['Cookie'].replace(
'wfMmjh3k/7Sr2xVNg/LtITgPRlnvGWBzP9a4FN0dn9PE7L5jDYiYJnW03MJLRUGHEFNCRhTfrp/V+wUj0dun1KkKNUUmS86A/wGVf6ydzhwboelTOs0hfHuF0ndtSoX+N3486tUMlm62VU4i856mqw==',
self.qtk)
def get_filter(self,text):
if isinstance(text, list):
text = ''.join(text)
text = str(text)
text = text.strip()
filter_list = [
'\r', '\n', '\t', '\u3000', '\xa0', '\u2002',
'<br>', '<br/>', ' ', ' ', '&nbsp;', '>>', '&quot;',
'展开全部', ' '
]
for fl in filter_list:
text = text.replace(fl, '')
return text
def get_qtv_qtk(self):
api_url = 'https://fanyi.qq.com/'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, '
'like Gecko) Chrome/73.0.3683.86 Safari/537.36', }
res = requests.get(api_url, headers=headers)
data = res.text
fy_guid = res.cookies.get('fy_guid')
reg = re.compile(r'var qtv = "(.*?)"')
qtv = reg.search(data).group(1)
reg = re.compile(r'var qtk = "(.*?)"')
qtk = reg.search(data).group(1)
return fy_guid, qtv, qtk
def getHtml(self,url,headers,data):
try:
html= requests.post(url=url,data= data,headers=headers)
#print(html.text)
datas = html.json()['translate']['records']
if html!=None and datas != None :
# 以文本的形式打印结果
trans_result = ''.join([data['targetText'] for data in datas])
return trans_result
except Exception:
return None
def translate(self,text):
data = {
'source': self.fromlang,
'target': self.tolang,
'sourceText': text,
'qtv': self.qtv,
'qtk': self.qtk,
'sessionUuid': self.sessionUuid, }
try:
result = self.getHtml(self.api_url,self.headers,data)
#print('腾讯翻译结果为:',result)
return result
except:
return '程序出现了一点小问题,无法翻译' class Translator(QWidget):
def __init__(self, parent=None, **kwargs):
super(Translator, self).__init__(parent)
self.setWindowTitle('翻译软件')
self.setWindowIcon(QIcon('data/icon.jpg'))
self.Label1 = QLabel('原文')
self.Label2 = QLabel('译文')
self.LineEdit1 = QLineEdit()
self.LineEdit2 = QLineEdit()
self.translateButton1 = QPushButton()
self.translateButton2 = QPushButton()
self.translateButton3 = QPushButton()
self.translateButton4 = QPushButton()
self.translateButton5 = QPushButton()
self.translateButton6 = QPushButton()
self.translateButton1.setText('百度翻译')
self.translateButton2.setText('有道翻译')
self.translateButton3.setText('谷歌翻译')
self.translateButton4.setText('词霸翻译')
self.translateButton5.setText('必应翻译')
self.translateButton6.setText('腾讯翻译')
self.grid = QGridLayout()
self.grid.setSpacing(12)
self.grid.addWidget(self.Label1, 1, 0)
self.grid.addWidget(self.Label2, 2, 0)
self.grid.addWidget(self.LineEdit1, 1, 1,1,2)
self.grid.addWidget(self.LineEdit2, 2, 1,1,2)
self.grid.addWidget(self.translateButton1, 3, 0)
self.grid.addWidget(self.translateButton2, 3, 1)
self.grid.addWidget(self.translateButton3, 3, 2)
self.grid.addWidget(self.translateButton4, 4, 0)
self.grid.addWidget(self.translateButton5, 4, 1)
self.grid.addWidget(self.translateButton6, 4, 2)
self.setLayout(self.grid)
self.resize(400, 150)
self.translateButton1.clicked.connect(lambda : self.translate(api='baidu'))
self.translateButton2.clicked.connect(lambda : self.translate(api='youdao'))
self.translateButton3.clicked.connect(lambda : self.translate(api='google'))
self.translateButton4.clicked.connect(lambda : self.translate(api='Ciba'))
self.translateButton5.clicked.connect(lambda : self.translate(api='bing'))
self.translateButton6.clicked.connect(lambda : self.translate(api='tencent'))
def translate(self, api='baidu'):
content = self.LineEdit1.text()
lan,tolan = language(content)
if not content:
return
if api == 'baidu':
results = Baidu().translate(content,lan,tolan)
elif api == 'youdao':
results = Youdao().translate(content,lan,tolan)
elif api == 'google':
results = Google().translate(content,lan,tolan)
elif api == 'Ciba':
results = Ciba(content,lan,tolan).translate()
elif api == 'bing':
results = Bing().translate(content,lan,tolan)
elif api =='tencent':
results = Tencent().translate(content)
self.LineEdit2.setText(results)
if __name__ == "__main__":
app = QApplication(sys.argv)
QApplication.processEvents()
demo = Translator()
demo.show()
sys.exit(app.exec_())

然后在cmd输入pyinstaller -F -w translate.py即可打包得到一个多接口翻译软件

python实现多接口翻译软件的更多相关文章

  1. python调用zabbix接口实现Action配置

    要写这篇博客其实我的内心是纠结的,老实说,我对zabbix的了解实在不多.但新公司的需求不容置疑,当我顶着有两个头大的脑袋懵懵转入运维领域时,面前摆着两百多组.上千台机器等着写入zabbix监控的需求 ...

  2. Python监控网站接口值

    Python监控网站接口值: #!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'liudong' import urllib,sy ...

  3. 关于python测试webservice接口的视频分享

    现在大公司非常流行用python做产品的测试框架,还有对于一些快速原型产品的开发也好,很好地支持OO编程,代码易读.Python的更新挺快的,尤其是第三方库. 对于测试人员,代码基础薄弱,用pytho ...

  4. python调用ice接口

    今天用python调用ice接口,遇到如下提示 ImportError: No module named Ice 解决方案是 set PYTHONPATH=C:\Program Files\ZeroC ...

  5. python+robot framework接口自动化测试

    python+requests实现接口的请求前篇已经介绍,还有不懂或者疑问的可以访问 python+request接口自动化框架 目前我们需要考虑的是如何实现关键字驱动实现接口自动化输出,通过关键字的 ...

  6. python实现微信接口(itchat)

    python实现微信接口(itchat) 安装 sudo pip install itchat 登录 itchat.auto_login() 这种方法将会通过微信扫描二维码登录,但是这种登录的方式确实 ...

  7. 用Python写WebService接口并且调用

    一.用ladon框架封装Python为Webservice接口 另用soaplib实现请看:    http://www.jianshu.com/p/ad3c27d2a946 功能实现的同时,希望将接 ...

  8. python入门以及接口自动化实践

    一.Python入门必备基础语法# 标识符:python中我们自己命名的都是标识符# 项目名 包名 模块名# 变量名 函数名 类名# 1:字母 下划线 数字组成 命名的时候不能以数字开头# 2:见名知 ...

  9. python实现微信接口——itchat模块

    python实现微信接口——itchat模块 安装 sudo pip install itchat 登录 itchat.auto_login()  这种方法将会通过微信扫描二维码登录,但是这种登录的方 ...

随机推荐

  1. MyBatis 03 缓存

    简介 什么是缓存 存在内存中的临时数据. 将用户经常查询的数据放在缓存(内存)中,用户去查询数据就不用从磁盘上(关系型数据库数据文件)查询,转从缓存中查询,从而提高查询效率,解决了高并发系统的性能问题 ...

  2. 自定义spring boot starter 初尝试

    自定义简单spring boot starter 步骤 从几篇博客中了解了如何自定义starter,大概分为以下几个步骤: 1 引入相关依赖: 2 生成属性配置类: 3 生成核心服务类: 4 生成自动 ...

  3. Python自学教程5-字符串有哪些常用操作

    任何编程语言,不管是Python.Java 还是 Golang, 字符串都是最重要的一种数据类型. 但是字符串的操作又很多,初学者经常毫无头绪,不知道从哪儿学起,也不知道哪些操作用得多,今天九柄就和你 ...

  4. 系统CPU飙高,怎么排查?

    cpu是整个电脑的核心计算资源,对于一个应用进程来说,cpu的最小执行单元是线程. 导致cpu飙高的原因有几个方面: cpu上下文切换过多,对于cpu来说,同一时刻下每个cpu核心只能运行一个线程,如 ...

  5. ARC120F Wine Thief (组合数学)

    题面 有一个长为 N N N 的序列,相邻的两个数中只能选一个,总共选 k k k 个数,一种方案的价值为选的 k k k 个数的和,问所有合法方案的价值总和,答案对 998244353 取模. 1 ...

  6. 闭包 与 js内存管理

    参考:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Memory_Management            https://blog ...

  7. JMeter测试dubbo接口总结

    Jmeter 测试dubbo 接口 1. 安装JMeter 安装到/usr/local下 2. github上下载 jmeter-plugins-dubbo-x.x.x-jar-with-depend ...

  8. 读完 RocketMQ 源码,我学会了如何优雅的创建线程

    RocketMQ 是一款开源的分布式消息系统,基于高可用分布式集群技术,提供低延时.高可靠的消息发布与订阅服务. 这篇文章,笔者整理了 RocketMQ 源码中创建线程的几点技巧,希望大家读完之后,能 ...

  9. OpenDataV低代码平台新增组件流程

    OpenDataV计划采用子库的方式添加子组件,即每一个组件都当做一个子库,子库有自己的依赖,而项目本身的依赖只针对框架,因此每一个组件我们都当做一个子库来开发.下面我带着大家一步步详细的开发一个数字 ...

  10. docker学习笔记一-docker安装与卸载

    环境查看 # 1 查询当前centOS的版本,官方要求版本为7以上 uname -r 查询系统内核 cat /etc/os-release 系统版本 安装 # 1.卸载旧版本 yum remove d ...