百度,有道,谷歌翻译API

API翻译

百度,有道,谷歌API翻译(只针对中英相互翻译),其他语言翻译需要对应from,to的code

百度翻译

package fills.tools.translate;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Set;

import javax.script.Invocable;

import javax.script.ScriptEngine;

import javax.script.ScriptEngineManager;

import org.apache.http.HttpEntity;

import org.apache.http.NameValuePair;

import org.apache.http.client.entity.UrlEncodedFormEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;

public class BaiduTranslateTools {

public static void main(String[] args) throws Exception{

     String en = doBdTranslate("测试一下", "zh", "en");

     String zh = doBdTranslate("test", "en", "zh");

     System.out.println(en);

     System.out.println(zh);

}

private static CloseableHttpClient httpClient = HttpClients.createDefault();

/**

 * 封装百度翻译请求参数

 * @param query

 * @param from  zh 

 * @param to  en

 * @return String

 * @throws Exception

 */

public static String doBdTranslate(String query,String from,String to)throws Exception{

     String url = "https://fanyi.baidu.com/v2transapi";

     Map<String,String> params = new HashMap<String,String>();

     params.put("from",from);

     params.put("to",to);

     params.put("transtype","translang");

     params.put("simple_means_flag","3");

     params.put("sign",runByJs(query,"sig",getBdJs()));

     params.put("token","75f7eb4170c6dba7a1d84c76611205c3");

     params.put("domain","common");

     params.put("query",query);

     return bdGetResult(bdTranslate(url, params));

}

/**

 * 封装百度翻译接口 模拟浏览器请求

 * @param url

 * @param map

 * @return String

 * @throws Exception

 */

private static String bdTranslate(String url,Map<String,String> map) throws Exception{

        try {

         HttpPost request = new HttpPost(url);

request.setEntity(new UrlEncodedFormEntity(map2list(map), "UTF-8"));

        request.setHeader("Cookie","BIDUPSID=518EFD25B0E401331F59B9BDC8388898; BAIDUID=DA7060B673236FB3427E0D66755262B9:FG=1; PSTM=1636594736; __yjs_duid=1_57b3cd04392832a6fbd32d39e48784831636600728790; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; BDUSS=phdjFZaTJRZ3lPeW1OaHg0WXFyMFgtNWZ6QXNkczh3cEd-Sn5INjg3dG9nc0poRVFBQUFBJCQAAAAAAAAAAAEAAACHLc4ceXNmd3p6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGj1mmFo9ZpheW; H_PS_PSSID=34446_35104_31254_35049_34584_34518_35245_34578_26350_35146; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1637568947; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1637569056; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; delPer=0; PSINO=2; BDRCVFR[Fc9oatPmwxn]=mk3SLVN4HKm; BA_HECTOR=8hag058g0gag8g218f1gpp7gb0r");

        request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0");

        request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

        request.setHeader("Host","fanyi.baidu.com");

        request.setHeader("Origin","https://fanyi.baidu.com");

        request.setHeader("Referer","https://fanyi.baidu.com/?aldtype=16047");

        request.setHeader("X-Requested-With","XMLHttpRequest");

        CloseableHttpResponse response = httpClient.execute(request);

        HttpEntity entity = response.getEntity();

        String result = EntityUtils.toString(entity, "UTF-8");

        EntityUtils.consume(entity);

        response.getEntity().getContent().close();

        response.close();

        return result;

        } catch (Exception e) {

throw e;

}

}

/**

 * 处理百度翻译结果

 * @param json

 * @return

 */

@SuppressWarnings({ "unchecked", "rawtypes" })

private static String bdGetResult(String json){

     Map<String ,Object> result = JSON.parseObject(json, Map.class);

     Map res  = (Map)result.get("trans_result");

     List<Map> r = (List<Map>)res.get("data");

     if(!r.isEmpty()){

          return (r.get(0).get("dst")+"").replace(",", "");

     }

     return null;

}

/**

 *

 * @param param 一个入参

 * @param method 方法

 * @param jsCode js 代码

 * @return String

 */

public static String runByJs(String param,String method,String jsCode){

     String res = null;

     try {

      ScriptEngine bdToken = new ScriptEngineManager().getEngineByName("js");

          bdToken.eval(jsCode);

          Invocable inv2 = (Invocable) bdToken;

          res =(String)inv2.invokeFunction(method,param);

} catch (Exception e) {

 res = null;

}

     return res;

    }

/**

 * 百度js 签名算法

 * @return String

 */

private static String getBdJs(){

StringBuffer bd = new StringBuffer();

bd.append("var i = '320305.131321201';                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ");

bd.append("function n(r, o) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ");

bd.append("    for (var t = 0; t < o.length - 2; t += 3) {                                                                                                                                                                                                                                                                                                                                                                                                                                             ");

bd.append("        var a = o.charAt(t + 2);                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("        a = a >= 'a' ? a.charCodeAt(0) - 87 : Number(a),                                                                                                                                                                                                                                                                                                                                                                                                                                    ");

bd.append("        a = '+' === o.charAt(t + 1) ? r >>> a: r << a,                                                                                                                                                                                                                                                                                                                                                                                                                                      ");

bd.append("        r = '+' === o.charAt(t) ? r + a & 4294967295 : r ^ a                                                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("    return r                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ");

bd.append("var sig = function e(r) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ");

bd.append("    var o = r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g);                                                                                                                                                                                                                                                                                                                                                                                                                                     ");

bd.append("    if (null === o) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("        var t = r.length;                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ");

bd.append("        t > 30 && (r = '' + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr( - 10, 10))                                                                                                                                                                                                                                                                                                                                                                                    ");

bd.append("    } else {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("        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(''))),                                                                                                                                                                                                                                                                                                                                  ");

bd.append("        C !== h - 1 && f.push(o[C]);                                                                                                                                                                                                                                                                                                                                                                                                                                                        ");

bd.append("        var g = f.length;                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ");

bd.append("        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(''))                                                                                                                                                                                                                                                                                                                                                  ");

bd.append("    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("    var u = void 0,                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ");

bd.append("    l = '' + String.fromCharCode(103) + String.fromCharCode(116) + String.fromCharCode(107);                                                                                                                                                                                                                                                                                                                                                                                                ");

bd.append("    u = null !== i ? i: (i = window[l] || '') || '';                                                                                                                                                                                                                                                                                                                                                                                                                                        ");

bd.append("    for (var d = u.split('.'), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) {                                                                                                                                                                                                                                                                                                                                                                     ");

bd.append("        var A = r.charCodeAt(v);                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("        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)                                                                                                                                  ");

bd.append("    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ");

bd.append("    for (var p = m,                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ");

bd.append("    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],        ");

bd.append("    p = n(p, F);                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("    return p = n(p, D),                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ");

bd.append("    p ^= s,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ");

bd.append("    0 > p && (p = (2147483647 & p) + 2147483648),                                                                                                                                                                                                                                                                                                                                                                                                                                           ");

bd.append("    p %= 1e6,                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ");

bd.append("    p.toString() + '.' + (p ^ m)                                                                                                                                                                                                                                                                                                                                                                                                                                                            ");

bd.append("}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ");

return bd.toString();

}

/**

 * 转换请求参数

 * @param paramsMap

 * @return

 */

private static List<? extends NameValuePair> map2list(Map<String, String> paramsMap) {

        List<NameValuePair> listParams = new ArrayList<NameValuePair>();

        Set<String> keys = paramsMap.keySet();

        for (String key : keys) {

             listParams.add(new BasicNameValuePair(key, paramsMap.get(key)));

        }

        return listParams;

    }

}

运行结果

有道翻译

package fills.tools.translate;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Set;

import org.apache.http.HttpEntity;

import org.apache.http.NameValuePair;

import org.apache.http.client.entity.UrlEncodedFormEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;

import fills.tools.md5.MD5Util;

import fills.tools.util.EncodingCheck;

public class YoudaoTranslateTools {

public static void main(String[] args) throws Exception{

        String en = doYdTranslate("测试一下", "zh", "en");

        String zh = doYdTranslate("test", "en", "zh");

        System.out.println(en);

        System.out.println(zh);

}

private static CloseableHttpClient httpClient = HttpClients.createDefault();

/**

 * 封装有道翻译请求参数

 * @param query

 * @param from  zh 

 * @param to  en

 * @return String

 * @throws Exception

 */

public static String doYdTranslate(String query,String from,String to) throws Exception{

        String newQuery = EncodingCheck.gbkToUtf8(query);

        String url = "https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule";

        Long time = System.currentTimeMillis();

       String slat = time+""+ (long) (Math.random() * 10 + 1);

       //签名算法

        String sign = MD5Util.md5("fanyideskweb" + newQuery + slat + "Y2FYu%TNSbMCxc3t2u^XT");

        Map<String,String> params = new HashMap<String,String>();

        params = new HashMap<String,String>();

        params.put("i", newQuery);

        //params.put("from", "AUTO");

        //params.put("to", "AUTO");

        params.put("from", from);

        params.put("to", to);

        params.put("smartresult", "dict");

        params.put("client", "fanyideskweb");

        params.put("salt", slat);

        params.put("sign", sign);

        params.put("doctype", "json");

        params.put("bv","e2a78ed30c66e16a857c5b6486a1d326");

        params.put("lts",""+time);

        params.put("version", "2.1");

        params.put("keyfrom", "fanyi.web");

        params.put("action", "FY_BY_CLICKBUTTION");

       return ydGetResult(YoudaoTranslateTools.ydTranslate(url, params));

}

/**

 * 封装有道翻译接口

 * @param url

 * @param map

 * @return

 * @throws Exception

 */

private static String ydTranslate(String url,Map<String,String> map) throws Exception{

        try {

         HttpPost request = new HttpPost(url);

request.setEntity(new UrlEncodedFormEntity(map2list(map), "UTF-8"));

        request.setHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");

        request.setHeader("Cookie","OUTFOX_SEARCH_USER_ID_NCOO=2112457812.6057248; OUTFOX_SEARCH_USER_ID=\"1568208620@10.105.137.204\"; YOUDAO_MOBILE_ACCESS_TYPE=1; JSESSIONID=aaaj85MpKF2HUbfaqhs1x; ___rl__test__cookies=1637913084476");

        request.setHeader("Host","fanyi.youdao.com");

        request.setHeader("Origin","https://fanyi.youdao.com");

        request.setHeader("Referer","https://fanyi.youdao.com");

        request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0");

        request.setHeader("X-Requested-With","XMLHttpRequest");

        CloseableHttpResponse response = httpClient.execute(request);

        HttpEntity entity = response.getEntity();

        String result = EntityUtils.toString(entity, "UTF-8");

        EntityUtils.consume(entity);

        response.getEntity().getContent().close();

        response.close();

        return result;

        } catch (Exception e) {

throw e;

}

}

/**

 * 处理有道翻译结果

 * @param json

 * @return

 */

@SuppressWarnings({ "unchecked", "rawtypes" })

private static String ydGetResult(String json){

        Map<String ,Object> result = JSON.parseObject(json, Map.class);

        List<List<Map>> res  = (List<List<Map>>)result.get("translateResult");

        if(!res.isEmpty()){

                return res.get(0).get(0).get("tgt")+"";

        }

        return null;

}

/**

 * 转换请求参数

 * @param paramsMap

 * @return

 */

private static List<? extends NameValuePair> map2list(Map<String, String> paramsMap) {

        List<NameValuePair> listParams = new ArrayList<NameValuePair>();

        Set<String> keys = paramsMap.keySet();

        for (String key : keys) {

             listParams.add(new BasicNameValuePair(key, paramsMap.get(key)));

        }

        return listParams;

    }

    

}

运行结果

谷歌翻译

谷歌翻译需要开启国外代理,网络不通

package fills.tools.translate;

import java.util.List;

import javax.script.Invocable;

import javax.script.ScriptEngine;

import javax.script.ScriptEngineManager;

import org.apache.http.HttpEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpGet;

import org.apache.http.client.utils.URIBuilder;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;

public class GoogleTranslateTools {

public static void main(String[] args) throws Exception{

        String en = doGoogleTranslate("测试一下", "zh", "en");

        String zh = doGoogleTranslate("test", "en", "zh");

        System.out.println(en);

        System.out.println(zh);

}

private static CloseableHttpClient httpClient = HttpClients.createDefault();

/**

 * 封装Goole参数信息

 * @param query

 * @param from zh-CN

 * @param to  en

 * @return String

 * @throws Exception

 */

public static String doGoogleTranslate(String query,String from,String to)throws Exception{

        String url = "https://translate.google.com.hk/translate_a/single?";

        String urlParam ="client=t&sl="+from+"&tl="+to+"&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&source=btn&ssel=0&tsel=0&kc=0&tk="+getGgJs(query,getGg())+"&q="+query;

     return ggGetResult(googleTranslate(url+urlParam));

}

/**

 * 封装Goole翻译请求

 * @param url

 * @return String

 * @throws Exception

 */

private static String googleTranslate(String url) throws Exception{

        try {

         URIBuilder uri = new URIBuilder(url);

         HttpGet request = new HttpGet(uri.toString());

request.setHeader("Cookie","NID=511=UKCb40FREknEZtX19ubTXHKnTj2fqh8YZePtu2eWf-ZXdPN_Rs35XiJGF_yjbW2oaSAz4XBJVYOc_2xYAYyQiD3IEoHBJqghUeumnQJdvjn95jqU71b00BtMl2mHwoNiMLYDZgCDBtqU2A5Ql6O3oVMhvGyPrY3CbSsp4kdhzmE; _ga=GA1.3.409789010.1640080107; _gid=GA1.3.27316764.1640080107");

        request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0");

        request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

        request.setHeader("Origin","https://translate.google.com.hk");

        request.setHeader("Referer","https://translate.google.com.hk/");

        request.setHeader("X-Requested-With","XMLHttpRequest");

        CloseableHttpResponse response = httpClient.execute(request);

        HttpEntity entity = response.getEntity();

        String result = EntityUtils.toString(entity, "UTF-8");

        EntityUtils.consume(entity);

        response.getEntity().getContent().close();

        response.close();

        return result;

        } catch (Exception e) {

throw e;

}

}

/**

 * 处理谷歌翻译结果

 * @param json

 * @return

 */

@SuppressWarnings({"rawtypes", "unused" })

private static String ggGetResult(String json){

        List result = JSON.parseObject(json, List.class);

        if(!result.isEmpty()){

                return ((List)((List)result.get(0)).get(0)).get(0)+"";

        }

        return null;

}

/**

 * 加载js获取签名信息

 * @param query

 * @param js

 * @return

 */

private static String getGgJs(String query,String js){

     String res = null;

     try {

      ScriptEngine bdToken = new ScriptEngineManager().getEngineByName("js");

          bdToken.eval(js);

          Invocable inv2 = (Invocable) bdToken;

          res =(String)inv2.invokeFunction("sig",query);

        } catch (Exception e) {

         res = null;

        }

     return res;

    }

    

   

    /**

     * google 签名 JS

     * @return String

     */

private static String getGg(){

     StringBuffer gg = new StringBuffer();

     gg.append("var sig = function sig(a) {                                                                                                                                                                                                                                                                                                                                          ");

gg.append("    var k = '';                                                                                                                                                                                                                                                                                                                                              ");

gg.append("    var b = 406644;                                                                                                                                                                                                                                                                                                                                          ");

gg.append("    var b1 = 3293161072;                                                                                                                                                                                                                                                                                                                                     ");

gg.append("                                                                                                                                                                                                                                                                                                                                                             ");

gg.append("    var jd = '.';                                                                                                                                                                                                                                                                                                                                            ");

gg.append("    var sb = '+-a^+6';                                                                                                                                                                                                                                                                                                                                       ");

gg.append("    var Zb = '+-3^+b+-f';                                                                                                                                                                                                                                                                                                                                    ");

gg.append("                                                                                                                                                                                                                                                                                                                                                             ");

gg.append("    for (var e = [], f = 0, g = 0; g < a.length; g++) {                                                                                                                                                                                                                                                                                                      ");

gg.append("        var m = a.charCodeAt(g);                                                                                                                                                                                                                                                                                                                             ");

gg.append("        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)     ");

gg.append("    }                                                                                                                                                                                                                                                                                                                                                        ");

gg.append("    a = b;                                                                                                                                                                                                                                                                                                                                                   ");

gg.append("    for (f = 0; f < e.length; f++) a += e[f],                                                                                                                                                                                                                                                                                                                ");

gg.append("    a = RL(a, sb);                                                                                                                                                                                                                                                                                                                                           ");

gg.append("    a = RL(a, Zb);                                                                                                                                                                                                                                                                                                                                           ");

gg.append("    a ^= b1 || 0;                                                                                                                                                                                                                                                                                                                                            ");

gg.append("    0 > a && (a = (a & 2147483647) + 2147483648);                                                                                                                                                                                                                                                                                                            ");

gg.append("    a %= 1E6;                                                                                                                                                                                                                                                                                                                                                ");

gg.append("    return a.toString() + jd + (a ^ b)                                                                                                                                                                                                                                                                                                                       ");

gg.append("};                                                                                                                                                                                                                                                                                                                                                           ");

gg.append("                                                                                                                                                                                                                                                                                                                                                             ");

gg.append("function RL(a, b) {                                                                                                                                                                                                                                                                                                                                          ");

gg.append("    var t = 'a';                                                                                                                                                                                                                                                                                                                                             ");

gg.append("    var Yb = '+';                                                                                                                                                                                                                                                                                                                                            ");

gg.append("    for (var c = 0; c < b.length - 2; c += 3) {                                                                                                                                                                                                                                                                                                              ");

gg.append("        var d = b.charAt(c + 2),                                                                                                                                                                                                                                                                                                                             ");

gg.append("        d = d >= t ? d.charCodeAt(0) - 87 : Number(d),                                                                                                                                                                                                                                                                                                       ");

gg.append("        d = b.charAt(c + 1) == Yb ? a >>> d: a << d;                                                                                                                                                                                                                                                                                                         ");

gg.append("        a = b.charAt(c) == Yb ? a + d & 4294967295 : a ^ d                                                                                                                                                                                                                                                                                                   ");

gg.append("    }                                                                                                                                                                                                                                                                                                                                                        ");

gg.append("    return a                                                                                                                                                                                                                                                                                                                                                 ");

gg.append("}                                                                                                                                                                                                                                                                                                                                                            ");                       

        return gg.toString();

    }

}

运行结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/49466.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ABAP+从SAP发出去的PDF文件在第三方系统出现乱码

这是一个 ABAP转换PDF调用函数CALL FUNCTION CONVERT_OTF的问题记录&#xff0c;关乎字体STSong-Light-ldentity-H 和 STSong-Light的区别 背景&#xff1a; 做了一个增强&#xff0c;是采购订单审批后自动发送采购订单PDF1到企业微信&#xff0c;用户再将企业微信收到的P…

最优化理论与方法-第十讲割平面法

文章目录 1. 原问题&#xff1a;2. 割平面法程序步骤2.1 第一次迭代2.2 第二次迭代2.3 第三次迭代 1. 原问题&#xff1a; 给定下列约束优化问题&#xff1a; ( P ) min ⁡ 3 x 1 2 2 x 2 2 s t . − 5 x 1 − 2 x 2 3 ≤ 0 , x ∈ X { x ∈ Z n ∣ 8 x 1 8 x 2 ≥ 1 , 0…

mysql的主从复制和读写分离:

mysql的主从复制和读写分离&#xff1a; 主从复制 面试必问&#xff1a;主从复制的原理 主从复制的模式&#xff1a; 1、mysql的默认模式&#xff1a; 异步模式 主库在更新完事务之后会立即把结果返回给从服务器&#xff0c;并不关心从库是否接受到&#xff0c;以及从库是…

【React】package.json 文件详解

文章目录 一、package.json 文件的基本结构二、package.json 文件的关键字段1. name 和 version2. description3. main4. scripts5. dependencies 和 devDependencies6. repository7. keywords8. author 和 license9. bugs 和 homepage 三、package.json 文件的高级配置1. 配置…

分享一个Springer模板关于论文作者和单位信息的修改范例,以及Applied Intelligence期刊latex模板的下载链接

在这篇文章中&#xff0c;我写一些关于解决springer期刊提供的LaTex模板参考文献格式为作者年份时的顺序问题以及如何在正文中将参考文献格式引用成[1]这种数字格式类似的经验&#xff0c;该篇帖子里还分享了一个大佬关于springer模板完整的修改流程&#xff0c;有需要的伙伴可…

全球电脑蓝屏崩溃,为何中国没事?周鸿祎:因 90% 用 360 软件!

2024 年 7 月 19 日&#xff0c;出现了震惊世界的微软蓝屏事件&#xff0c;全球近千万台 Windows 设备集体蓝屏宕机&#xff01; 这次的事件绝对称得上是 “载入史册”&#xff01;甚至百度百科都专门针对这次的事件出了一个词条、央视新闻也专门报道了此事。 这次事件的影响有…

ActiViz实战:二维纹理贴图vtkTexture

文章目录 一、效果预览二、基本概念三、功能特性四、与C++不同五、完整示例代码一、效果预览 二、基本概念 vtkTexture是VTK(Visualization Toolkit)中用于纹理映射的一个类,它允许用户将二维图像(纹理)贴到三维物体的表面上,从而增加场景的真实感和细节。 纹理映射:是一…

PY32F071单片机,主频最高72兆,资源丰富,有USB,DAC,运放

PY32F071 系列单片机是基于32 位 ARM Cortex-M0 内核的微控制器&#xff0c;宽电压工作范围的 MCU。芯片嵌入高达 128 Kbytes flash 和 16 Kbytes SRAM 存储器&#xff0c;最高72 MHz工作频率。芯片支持串行调试 (SWD)。PY32F071单片机提供了包含了HAL和LL两种不同层次的驱动库…

自定义webIpad证件相机(webRTC)

该技术方案可用于各浏览器自定义相机开发 相机UI&#xff08;index.html&#xff09; <!DOCTYPE html> <html lang"zh" prew"-1"><head><meta charset"UTF-8"><meta name"viewport"content"user-sc…

Llama 3.1要来啦?!测试性能战胜GPT-4o

哎呀&#xff0c;Meta声称将于今晚发布的Llama 3.1&#xff0c;数小时前就在Hugging Face上泄露出来了&#xff1f;泄露的人很有可能是Meta员工&#xff1f; 还是先来看泄露出来的llama3.1吧。新的Llama 3.1模型包括8B、70B、405B三个版本。 而经过网友测试&#xff0c;该base…

Spark实时(二):StructuredStreaming编程模型

文章目录 StructuredStreaming编程模型 一、基础语义 二、事件时间和延迟数据 三、​​​​​​​​​​​​​​容错语义 StructuredStreaming编程模型 一、基础语义 Structured Streaming处理实时数据思想是将实时数据看成一张没有边界的表&#xff0c;数据源源不断的追…

年化22.8%的单因子分析:基于Alphalens做可转债全市场数据的单因子分析(附python代码+全量数据)

原创文章第597篇&#xff0c;专注“AI量化投资、世界运行的规律、个人成长与财富自由"。 因子分析是量化研究的基本技能之一。通过因子分析&#xff0c;找出有效的因子&#xff0c;通过相关性去重后&#xff0c;就可以通过机器学习、线性回归等方法把因子组合起来&#xf…

Linux基础学习day1

1.Linux系统介绍 1.常见的操作系统 1.Windows&#xff08;NT内核&#xff09;不开源 2.ubantu&#xff08;linux内核&#xff09; 3.ios&#xff08;unix内核&#xff09;不开源 4.鸿蒙&#xff08;兼容linux内核&#xff09; 5.Android&#xff08;linux内核&#xff09…

STM32(七):STM32指南者-通信实验

目录 一、基本概念通讯基本概念1、串行和并行2、同步通讯与异步通讯3、全双工、半双工、单工4、通讯速率 USART基本概念1、串口通讯基本概念2、物理层3、协议层4、指南者的串口USART I2C基本概念SPI基本概念 二、USART串口实验前期准备1、安装安装 USB 转串口驱动_CH3402、野火…

Git之repo sync -l与repo forall -c git checkout用法区别(四十九)

简介&#xff1a; CSDN博客专家&#xff0c;专注Android/Linux系统&#xff0c;分享多mic语音方案、音视频、编解码等技术&#xff0c;与大家一起成长&#xff01; 优质专栏&#xff1a;Audio工程师进阶系列【原创干货持续更新中……】&#x1f680; 优质专栏&#xff1a;多媒…

微信各平台历史版本含下载地址大全( 安卓 | Windows | MAC )

微信-windows-版本历史 https://github.com/tom-snow/wechat-windows-versions/releases 微信-windows-x86版本历史 https://github.com/tom-snow/wechat-windows-versions-x86/releases 微信安卓版本历史 https://github.com/DJB-Developer/wechat-android-history-version…

Apache DolphinScheduler 3.2.2 版本正式发布!

Apache DolphinScheduler 3.2.2 版本正式发布&#xff01; 近日&#xff0c;Apache DolphinScheduler 发布了 3.2.2 版本。此版本主要基于 3.2.1 版本进行了 bug 修复&#xff0c;新增若干特性&#xff0c;并进行了众多改进和 Bug 修复&#xff0c;以及文档修复等。 &#x1…

电路学习——经典运放电路之滞回比较器(施密特触发器)(2024.07.18)

参考链接1: 电子设计教程29&#xff1a;滞回比较器&#xff08;施密特触发器&#xff09; 参考链接2: 滞回比较器电路详细分析 参考链接3: 比较器精髓&#xff1a;施密特触发器&#xff0c;正反馈的妙用 参考链接4: 比较器反馈电阻选多大&#xff1f;理解滞后效应&#xff0c;轻…

【iOS】进程与多线程

目录 前言进程和线程进程和线程的区别多线程的意义时间片概念 线程的生命周期线程池的运行策略自旋锁和互斥锁自旋锁互斥锁自旋锁和互斥锁区别原子属性 iOS多线程技术方案 前言 学习此文&#xff1a;iOS多线程 在平时的iOS开发中&#xff0c;多线程是我们常会遇到的&#xff0…

新手教学系列——如何在MacOS 10.13.6(老系统)手动安装和配置Pyenv

前言 对于使用老旧系统&#xff08;如MacOS 10.13.6&#xff09;的用户来说&#xff0c;安装和管理Python版本可能会遇到一些挑战。特别是由于Homebrew不再支持老系统&#xff0c;许多软件安装变得困难重重。本文将详细介绍如何在这样的环境下手动安装和配置Pyenv&#xff0c;…