最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python django框架輸入漢字,數(shù)字,字符生成二維碼實(shí)現(xiàn)詳解

 更新時(shí)間:2019年09月24日 10:46:43   作者:張丶耀慶  
這篇文章主要介紹了Python django框架輸入漢字,數(shù)字,字符轉(zhuǎn)成二維碼實(shí)現(xiàn)詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了Python django框架輸入漢字,數(shù)字,字符轉(zhuǎn)成二維碼實(shí)現(xiàn)詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

模塊必備:Python環(huán)境 + pillow + qrcode 模塊

核心代碼<br>import qrcode
 
qr = qrcode.QRCode(
      version=2,
      error_correction=qrcode.constants.ERROR_CORRECT_L,
      box_size=20,
      border=4,
    )
qr.add_data('你要生成的文件')
qr.make(fit=True)
img = qr.make_image()
# 只需要改成自己的路徑
img.save('text.png')  <br># img.save('/Users/admin/PycharmProjects/str_code/statics/assets/png/'+'text.png')

django views函數(shù)代碼!路由自己設(shè)置就可以。

from django.shortcuts import render
 
# Create your views here.
 
 
import qrcode
# python-qrcode是個(gè)用來(lái)生成二維碼圖片的第三方模塊,依賴于 PIL 模塊和 qrcode 庫(kù)。
 
 
def str_decode_code(request):
  print(request.method)
  if request.method == 'GET':
    return render(request,'index.html')
  if request.method== 'POST':
    text = request.POST.get('message')
    print(text)
 
    qr = qrcode.QRCode(
      version=2,
      error_correction=qrcode.constants.ERROR_CORRECT_L,
      box_size=20,
      border=4,
    )
    qr.add_data(text)
    qr.make(fit=True)
    img = qr.make_image()
    # 只需要改成自己的路徑
    img.save('/Users/admin/PycharmProjects/str_code/statics/assets/png/'+'text.png')
    return render(request,'en_index.html',{'mgs':text}) 

前段代碼

<!DOCTYPE html>
<html lang="en">
   
  <head>
    <meta charset="utf-8">
    <title>二維碼生成器</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="keywords" content="二維碼生成器,二維碼掃描,二維碼制作,二維碼解碼,微信二維碼,二維碼名片,QR code,二維碼是什么,微信二維碼">
    <meta name="description" content="二維碼生成器是國(guó)內(nèi)免費(fèi)二維碼在線服務(wù)網(wǎng)站,功能簡(jiǎn)單、方便、快捷。織夢(mèng)二維碼解決方案應(yīng)用于各類網(wǎng)站,無(wú)論是商業(yè)應(yīng)用還是個(gè)人創(chuàng)業(yè)都是首選。">
    <link href="../statics/assets/css/bootstrap.css" rel="external nofollow" rel="stylesheet">
    <link href="../statics/assets/css/bootstrap-colorpicker.min.css" rel="external nofollow" rel="stylesheet">
    <style type="text/css">body {
        padding-top: 60px;
        padding-bottom: 40px;
       }
#flink li a {
  color:#999;
}
    </style>
    <link href="../statics/assets/css/bootstrap-responsive.css" rel="external nofollow" rel="stylesheet">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../statics/assets/ico/apple-touch-icon-144-precomposed.png.html" rel="external nofollow" >
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../statics/assets/ico/apple-touch-icon-114-precomposed.png.html" rel="external nofollow" >
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../statics/assets/ico/apple-touch-icon-72-precomposed.png.html" rel="external nofollow" >
    <link rel="apple-touch-icon-precomposed" href="../statics/assets/ico/apple-touch-icon-57-precomposed.png.html" rel="external nofollow" >
    <link rel="shortcut icon" href="../statics/assets/ico/favicon.png.html" rel="external nofollow" >
  </head>
   
  <body>
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span>
 <span class="icon-bar"></span>
 <span class="icon-bar"></span>
          </button> <a class="brand" href="index.html" rel="external nofollow" >二維碼生成器</a>
        </div>
      </div>
    </div>
    <div class="container">
      <div class="container">
        <header class="jumbotron subhead" id="overview">
           <h1>生成二維碼</h1>
          <p class="lead">用于制作生成二維碼,方便各類客戶端(例如:微信、淘寶、移動(dòng)瀏覽器)進(jìn)行掃描。</p>
        </header>
        <form action="/code/code" method="post">
        <ul id="myTab" class="nav nav-tabs">
          <li class="active"><a href="#" rel="external nofollow" >文本</a>
          </li>
 
        </ul>
        <div class="row">
          <div class="span5">
            <label>明文:</label>
              <p>
                <textarea name="message" class="span5" style="height: 500px"></textarea>
              </p>
          </div>
          <div class="span2 encrypt_type">
 
            <button style="margin-top:250px" class="btn btn-primary" onclick="submsg()" >生成二維碼 -></button>
          </div>
          <div class="span5">
            <label>二維碼:</label>
            <div style="height: 500px;border:1px solid #000">
{#              圖片#}
 
            </div>
          </div>
        </div>
        </form>
      </div>
 
      <hr>
      <footer>
{#        <p>CopyRight 2015 <a href="" target=" rel="external nofollow" _blank"></a><strong></strong></p>#}
      </footer>
    </div>
    <script src="../statics/assets/js/jquery-1.11.2.min.js"></script>
    <script src="../statics/assets/js/bootstrap.min.js"></script>
    <script src="../statics/assets/js/bootstrap-colorpicker.js"></script>
{#    <script>#}
{#      function submsg(){#}
{##}
{#      }#}
{#    </script>#}
 
  </body>
 
</html>

這樣就可以動(dòng)態(tài)生成二維碼了。

做好的二維碼,訪問地址:http://qrcode.ipgou.net/

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python scikit-learn數(shù)據(jù)預(yù)處理常見方法和步驟

    Python scikit-learn數(shù)據(jù)預(yù)處理常見方法和步驟

    數(shù)據(jù)預(yù)處理是數(shù)據(jù)準(zhǔn)備階段的一個(gè)重要環(huán)節(jié),主要目的是將原始數(shù)據(jù)轉(zhuǎn)換成適合機(jī)器學(xué)習(xí)模型使用的格式,數(shù)據(jù)預(yù)處理可以顯著提高機(jī)器學(xué)習(xí)模型的性能和準(zhǔn)確度,本文給大家介紹了Python數(shù)據(jù)預(yù)處理常見方法和步驟,需要的朋友可以參考下
    2024-05-05
  • Python實(shí)現(xiàn)二叉樹的常見遍歷操作總結(jié)【7種方法】

    Python實(shí)現(xiàn)二叉樹的常見遍歷操作總結(jié)【7種方法】

    這篇文章主要介紹了Python實(shí)現(xiàn)二叉樹的常見遍歷操作,結(jié)合實(shí)例形式總結(jié)分析了二叉樹的前序、中序、后序、層次遍歷中的迭代與遞歸等7種操作方法,需要的朋友可以參考下
    2019-03-03
  • python3使用騰訊企業(yè)郵箱發(fā)送郵件的實(shí)例

    python3使用騰訊企業(yè)郵箱發(fā)送郵件的實(shí)例

    今天小編就為大家分享一篇python3使用騰訊企業(yè)郵箱發(fā)送郵件的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2019-06-06
  • 聊聊pytorch測(cè)試的時(shí)候?yàn)楹我由蟤odel.eval()

    聊聊pytorch測(cè)試的時(shí)候?yàn)楹我由蟤odel.eval()

    這篇文章主要介紹了聊聊pytorch測(cè)試的時(shí)候?yàn)楹我由蟤odel.eval()的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-05-05
  • python過濾字符串中不屬于指定集合中字符的類實(shí)例

    python過濾字符串中不屬于指定集合中字符的類實(shí)例

    這篇文章主要介紹了python過濾字符串中不屬于指定集合中字符的類,涉及Python針對(duì)字符串與集合的相關(guān)操作技巧,需要的朋友可以參考下
    2015-06-06
  • pytorch實(shí)現(xiàn)從本地加載 .pth 格式模型

    pytorch實(shí)現(xiàn)從本地加載 .pth 格式模型

    今天小編就為大家分享一篇pytorch實(shí)現(xiàn)從本地加載 .pth 格式模型,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2020-02-02
  • Python實(shí)現(xiàn)多張圖片合成一張馬賽克圖片

    Python實(shí)現(xiàn)多張圖片合成一張馬賽克圖片

    這篇文章主要介紹了了Python如何實(shí)現(xiàn)將多張圖片合成一張馬賽克圖片。文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)Python有一定的幫助,感興趣的可以學(xué)習(xí)一下
    2021-12-12
  • import的本質(zhì)解析

    import的本質(zhì)解析

    import是我們經(jīng)常使用的功能,方法大家也都會(huì)。雖然用的多,但它的本質(zhì)我們似乎沒有好好的了解過。本文就import的本質(zhì)解析,向大家作了介紹,需要的朋友可以參考下。
    2017-10-10
  • Python異常之常見的Bug類型解決方法

    Python異常之常見的Bug類型解決方法

    這篇文章主要介紹了Python異常之常見的Bug類型解決方法,主要分享一些粗心導(dǎo)致和知識(shí)不熟練導(dǎo)致的語(yǔ)法錯(cuò)誤以及被迫掉坑等內(nèi)容,文章介紹非常詳細(xì)需要的小伙伴可以參考一下
    2022-03-03
  • python爬取晉江文學(xué)城小說(shuō)評(píng)論(情緒分析)

    python爬取晉江文學(xué)城小說(shuō)評(píng)論(情緒分析)

    這篇文章主要介紹了使用python爬取晉江文學(xué)城小說(shuō)評(píng)論(情緒分析),全文代碼詳細(xì),邏輯清晰,很適合學(xué)習(xí)爬蟲爬取的朋友,需要的朋友可以參考下
    2021-04-04

最新評(píng)論

六盘水市| 姜堰市| 伊金霍洛旗| 荥经县| 志丹县| 特克斯县| 灵璧县| 自治县| 偏关县| 宝坻区| 微博| 玉龙| 鹿邑县| 祁连县| 砚山县| 北安市| 柳江县| 巢湖市| 仁寿县| 英超| 平度市| 武功县| 彭山县| 鄂托克前旗| 沾益县| 日喀则市| 霍山县| 井冈山市| 毕节市| 乌鲁木齐市| 汕尾市| 安康市| 金阳县| 黄石市| 文成县| 肥城市| 邵阳市| 习水县| 民权县| 北票市| 乌什县|