標籤:info 結構 jquery nim get url wget card style
參考文檔:
Python二維碼產生庫qrcode安裝和使用樣本:http://www.jb51.net/article/58579.htm
vCard格式參數詳細說明:http://www.phpin.net/thread-280-1-1.html
二維碼產生工具:http://tools.jb51.net/transcoding/jb51qrcode
準備環境:
系統版本:CentOS release 6.5
安裝pip:yum install python-pip
安裝qrcode: pip install qrcode
安裝web.py:官網下載包:web.py-0.40.dev0.tar.gz
安裝pil:下載包:wget http://effbot.org/media/downloads/Imaging-1.1.5.tar.gz
建立目錄:
項目目錄:/root/erweima
整個目錄結構如下,
[[email protected] erweima]# tree
.
├── static
│ ├── CardImg
│ ├── css
│ │ └── animate.css
│ ├── images
│ │ ├── banner.jpg
│ │ ├── logo.png
│ │ └── sss.png
│ └── js
│ └── jquery.min.js
├── templates
│ └── index.html
├── weixin.py
└── weixin.pyc
代碼編寫:
列出部分代碼
[[email protected] erweima]# cat weixin.py
# -*-coding:utf-8 -*-
import web
import qrcode
import time
from PIL import Image
urls = (
‘/‘,‘Index‘
)
render = web.template.render(‘templates‘)
def Code(info):
......
return imgpath
class Index(object):
def GET(self):
return render.index()
def POST(self):
info = web.input()
print info
return Code(info)
if __name__ ==‘__main__‘:
web.application(urls,globals()).run()
測試:
啟動,頁面產生二維碼
使用帳號掃碼,裡面是一個通訊錄,可以儲存到手機通訊錄。(qq也可以掃)
Python建立二維碼通訊錄