<i id='1922M'><tr id='1922M'><dt id='1922M'><q id='1922M'><span id='1922M'><b id='1922M'><form id='1922M'><ins id='1922M'></ins><ul id='1922M'></ul><sub id='1922M'></sub></form><legend id='1922M'></legend><bdo id='1922M'><pre id='1922M'><center id='1922M'></center></pre></bdo></b><th id='1922M'></th></span></q></dt></tr></i><div id='1922M'><tfoot id='1922M'></tfoot><dl id='1922M'><fieldset id='1922M'></fieldset></dl></div>
      1. <tfoot id='1922M'></tfoot>

        <legend id='1922M'><style id='1922M'><dir id='1922M'><q id='1922M'></q></dir></style></legend>
      2. <small id='1922M'></small><noframes id='1922M'>

        • <bdo id='1922M'></bdo><ul id='1922M'></ul>

        »ùÓÚPythonÖÆ×÷Ò»¸öÎı¾·­ÒëÆ÷

        ʱ¼ä£º2023-12-17

          <bdo id='Or3os'></bdo><ul id='Or3os'></ul>

          • <small id='Or3os'></small><noframes id='Or3os'>

                  <legend id='Or3os'><style id='Or3os'><dir id='Or3os'><q id='Or3os'></q></dir></style></legend>
                    <tbody id='Or3os'></tbody>
                  <i id='Or3os'><tr id='Or3os'><dt id='Or3os'><q id='Or3os'><span id='Or3os'><b id='Or3os'><form id='Or3os'><ins id='Or3os'></ins><ul id='Or3os'></ul><sub id='Or3os'></sub></form><legend id='Or3os'></legend><bdo id='Or3os'><pre id='Or3os'><center id='Or3os'></center></pre></bdo></b><th id='Or3os'></th></span></q></dt></tr></i><div id='Or3os'><tfoot id='Or3os'></tfoot><dl id='Or3os'><fieldset id='Or3os'></fieldset></dl></div>
                1. <tfoot id='Or3os'></tfoot>

                  Èç¹ûÒª»ùÓÚPythonÖÆ×÷Ò»¸öÎı¾·­ÒëÆ÷£¬ÎÒÃÇ¿ÉÒÔʹÓÃPythonµÄ»úÆ÷·­Òë¿â¡ª¡ªGoogletransºÍBaiduTranslate£¬ÕâÁ½¸ö¿â¿ÉÒÔʵÏÖÎı¾µÄ×Ô¶¯·­Òë¡£

                  ÒÔÏÂÊÇÖÆ×÷Îı¾·­ÒëÆ÷µÄÍêÕû¹¥ÂÔ£º

                  ²½Öè1£º°²×°»úÆ÷·­Òë¿â

                  ÎÒÃÇÐèÒªÏÂÔغͰ²×°PythonµÄ»úÆ÷·­Òë¿â¡ª¡ªGoogletransºÍBaiduTranslate¡£ÆäÖУ¬Googletrans¿ÉÒÔÖ±½Ó´Ópip°²×°£¬BaiduTranslateÐèÒª´ÓGitHubÉÏÏÂÔØÔ´´úÂë²¢ÊÖ¶¯°²×°¡£

                  ʾÀý´úÂ룺

                  # °²×° Googletrans
                  pip install googletrans==4.0.0rc1
                  
                  # ÏÂÔØ BaiduTranslate Ô´´úÂë²¢ÊÖ¶¯°²×°
                  git clone https://github.com/Mouse0w0/YouDaoTranslate.git
                  cd YouDaoTranslate
                  python setup.py install
                  

                  ²½Öè2£ºµ¼Èë»úÆ÷·­Òë¿â

                  ÎÒÃÇÐèÒªÔÚPython´úÂëÖе¼ÈëGoogletransºÍBaiduTranslate¿â¡£

                  ʾÀý´úÂ룺

                  # µ¼ÈëGoogletrans
                  from googletrans import Translator
                  
                  # µ¼ÈëBaiduTranslate
                  from youdao_trans import Translator as YoudaoTranslator
                  

                  ²½Öè3£º±àд·­Ò뺯Êý

                  ÎÒÃÇÐèÒª±àдһ¸ö·­ÒëµÄº¯Êý£¬Õâ¸öº¯ÊýÐèÒª½«ÊäÈëµÄÎı¾½øÐз­Ò룬Ȼºó·µ»Ø·­Òë½á¹û¡£

                  ʾÀý´úÂ룺

                  # ¶¨Òå·­Ò뺯Êý£¬Ê¹Óà Googletrans ½øÐз­Òë
                  def google_trans(text, dest='zh-CN'):
                      translator = Translator(service_urls=['translate.google.cn'])
                      trans = translator.translate(text, dest)
                      return trans.text
                  
                  # ¶¨Òå·­Ò뺯Êý£¬Ê¹Óà BaiduTranslate ½øÐз­Òë
                  def baidu_trans(text, dest='zh'):
                      APP_ID = 'ÄãµÄ°Ù¶È·­ÒëAPP_ID'
                      SECRET_KEY = 'ÄãµÄ°Ù¶È·­ÒëSECRET_KEY'
                      translator = YoudaoTranslator(APP_ID, SECRET_KEY)
                      trans = translator.translate(text, dest)
                      return trans
                  

                  ²½Öè4£º²âÊÔ·­Ò뺯Êý

                  ±àдºÃ·­Ò뺯Êýºó£¬ÎÒÃÇ¿ÉÒÔ±àдһ¸ö²âÊÔº¯ÊýÀ´²âÊÔ·­Ò뺯ÊýÊÇ·ñÕý³£¹¤×÷¡£

                  ʾÀý´úÂ룺

                  # ²âÊÔ·­Ò뺯Êý
                  def test_trans():
                      # ²âÊÔ Googletrans
                      print(google_trans('hello'))  # ÄãºÃ
                      print(google_trans('hello', 'ja'))  # ¤³¤ó¤Ë¤Á¤Ï
                  
                      # ²âÊÔ BaiduTranslate
                      print(baidu_trans('hello'))  # {'translation': ['ÄãºÃ'], 'dict': None, 'webdict': None, 'query': 'hello', 'errorCode': '0'}
                      print(baidu_trans('hello', 'ja'))  # {'translation': ['ÄãºÃ'], 'dict': None, 'webdict': None, 'query': 'hello', 'errorCode': '0'}
                  

                  ÍêÕû´úÂë

                  ÒÔÏÂÊÇÍêÕûµÄÎı¾·­ÒëÆ÷´úÂ룬¿ÉÒÔ¸ù¾ÝÐèÒª½øÐÐÐ޸ĺÍÓÅ»¯¡£

                  from googletrans import Translator
                  from youdao_trans import Translator as YoudaoTranslator
                  
                  # ¶¨Òå·­Ò뺯Êý£¬Ê¹Óà Googletrans ½øÐз­Òë
                  def google_trans(text, dest='zh-CN'):
                      translator = Translator(service_urls=['translate.google.cn'])
                      trans = translator.translate(text, dest)
                      return trans.text
                  
                  # ¶¨Òå·­Ò뺯Êý£¬Ê¹Óà BaiduTranslate ½øÐз­Òë
                  def baidu_trans(text, dest='zh'):
                      APP_ID = 'ÄãµÄ°Ù¶È·­ÒëAPP_ID'
                      SECRET_KEY = 'ÄãµÄ°Ù¶È·­ÒëSECRET_KEY'
                      translator = YoudaoTranslator(APP_ID, SECRET_KEY)
                      trans = translator.translate(text, dest)
                      return trans
                  
                  # ²âÊÔ·­Ò뺯Êý
                  def test_trans():
                      # ²âÊÔ Googletrans
                      print(google_trans('hello'))  # ÄãºÃ
                      print(google_trans('hello', 'ja'))  # ¤³¤ó¤Ë¤Á¤Ï
                  
                      # ²âÊÔ BaiduTranslate
                      print(baidu_trans('hello'))  # {'translation': ['ÄãºÃ'], 'dict': None, 'webdict': None, 'query': 'hello', 'errorCode': '0'}
                      print(baidu_trans('hello', 'ja'))  # {'translation': ['ÄãºÃ'], 'dict': None, 'webdict': None, 'query': 'hello', 'errorCode': '0'}
                  
                  # Ö´ÐвâÊÔº¯Êý
                  test_trans()
                  

                  ÒÔÉϾÍÊÇÖÆ×÷Îı¾·­ÒëÆ÷µÄÍêÕû¹¥ÂÔ¡£

                  ÉÏһƪ£ºÏê½âpythonʱ¼äÄ£¿éÖеÄdatetimeÄ£¿é ÏÂһƪ£ºÈçºÎÀûÓÃopencvÅжÏÁ½ÕÅͼƬÊÇ·ñÏàͬÏê½â

                  Ïà¹ØÎÄÕÂ

                  <i id='mk1cx'><tr id='mk1cx'><dt id='mk1cx'><q id='mk1cx'><span id='mk1cx'><b id='mk1cx'><form id='mk1cx'><ins id='mk1cx'></ins><ul id='mk1cx'></ul><sub id='mk1cx'></sub></form><legend id='mk1cx'></legend><bdo id='mk1cx'><pre id='mk1cx'><center id='mk1cx'></center></pre></bdo></b><th id='mk1cx'></th></span></q></dt></tr></i><div id='mk1cx'><tfoot id='mk1cx'></tfoot><dl id='mk1cx'><fieldset id='mk1cx'></fieldset></dl></div>

                    <small id='mk1cx'></small><noframes id='mk1cx'>

                    <tfoot id='mk1cx'></tfoot>
                      <legend id='mk1cx'><style id='mk1cx'><dir id='mk1cx'><q id='mk1cx'></q></dir></style></legend>

                      • <bdo id='mk1cx'></bdo><ul id='mk1cx'></ul>