memoの二维码分享WiFi
用下面的网址就好了。
https://zxing.appspot.com/generator
不自己动手多没意思!借助python,自己生成一下。
二维码生成库
pip install qrcode,使用方法看这里。出于记录目的,贴下来:
Usage
From the command line, use the installed qr script:
qr "Some text" > test.png
Or in Python, use the make shortcut function:
import qrcode
img = qrcode.make('Some data here')
Advanced Usage
For more control, use the QRCode class. For example:
import qrcode
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data('Some data')
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
The version parameter is an integer from 1 to 40 that controls the size of the QR Code (the smallest, version 1, is a 21x21 matrix). Set to None and use the fit parameter when making the code to determine this automatically.
fill_color and back_color can change the background and the painting color of the QR, when using the default image factory.
The error_correction parameter controls the error correction used for the QR Code. The following four constants are made available on the qrcode package:
ERROR_CORRECT_L
About 7% or less errors can be corrected.
ERROR_CORRECT_M (default)
About 15% or less errors can be corrected.
ERROR_CORRECT_Q
About 25% or less errors can be corrected.
ERROR_CORRECT_H
About 30% or less errors can be corrected.
The box_size parameter controls how many pixels each "box" of the QR code is.
The border parameter controls how many boxes thick the border should be (the default is 4, which is the minimum according to the specs).
手机扫描wifi的格式
通用wifi的格式:WIFI:T:WPA;S:mynetwork;P:mypass;;
可以应付大多数情况了。如果有其他需求,详见这里。不过出于记录的目的,原文贴下来:
| Parameter | Example | Description |
|---|---|---|
| T | WPA | Authentication type; can be WEP or WPA or WPA2-EAP, or nopass for no password. Or, omit for no password. |
| S | mynetwork | Network SSID. Required. Enclose in double quotes if it is an ASCII name, but could be interpreted as hex (i.e. "ABCD") |
| P | mypass | Password, ignored if T is nopass (in which case it may be omitted). Enclose in double quotes if it is an ASCII name, but could be interpreted as hex (i.e. "ABCD") |
| H | true | Optional. True if the network SSID is hidden. Note this was mistakenly also used to specify phase 2 method in releases up to 4.7.8 / Barcode Scanner 3.4.0. If not a boolean, it will be interpreted as phase 2 method (see below) for backwards-compatibility |
| E | TTLS | (WPA2-EAP only) EAP method, like TTLS or PWD |
| A | anon | (WPA2-EAP only) Anonymous identity |
| I | myidentity | (WPA2-EAP only) Identity |
| PH2 | MSCHAPV2 | (WPA2-EAP only) Phase 2 method, like MSCHAPV2 |
Order of fields does not matter. Special characters \, ;, ,, " and : should be escaped with a backslash (\) as in MECARD encoding. For example, if an SSID was literally "foo;bar\baz" (with double quotes part of the SSID name itself) then it would be encoded like: WIFI:S:\"foo\;bar\\baz\";;
示例代码
下面是我的代码:
from qrcode import QRCode
import colorama
def GenerateYourWifi(
type: str, ssid: str, psswd: str, outputPath: str = None, preview: bool = True
):
content = f"WIFI:T:{type};S:{ssid};P:{psswd};;"
c = QRCode()
c.add_data(content)
if preview:
colorama.init()
c.make()
c.print_tty()
if outputPath:
c.make_image().save(outputPath)
if __name__ == "__main__":
ssid = "my-sweet-home"
psswd = "12345678"
GenerateYourWifi("WPA", ssid, psswd)
其他有趣的东西
memoの二维码分享WiFi的更多相关文章
- 开源)嗨,Java,你可以生成金山词霸的二维码分享海报吗?
As long as you can still grab a breath, you fight.只要一息尚存,就不得不战. 有那么一段时间,我特别迷恋金山词霸的每日一句分享海报.因为不仅海报上的图 ...
- 微信小程序之生成图片分享 二维码分享 canvas绘制
如果本文对你有用,请爱心点个赞,提高排名,帮助更多的人.谢谢大家!❤ 如果解决不了,可以在文末进群交流. 添加画布 首先,在小程序里进行绘图操作需要用到<canvas>组件,步骤大致分为以 ...
- 安卓四核PDA手持PDA智能POS机 打印二维码 分享
很多项目都会用到 类似的要求 移动手持终端 通过程序 可以生成条码或二维码 打印出小票或标签纸 下面直接上代码 希望对大家有点用处 private void print(){ csys.setTex ...
- 二维码的妙用:通过Zxing实现wifi账号password分享功能
二维码是搭载信息的一种载体,通过二维码能够传递名片.网址.商品信息等,本文讲到二维码的第二种妙用:通过二维码实现wifi账号和password分享. 关于二维码的基础知识,请訪问:二维码的生成细节和原 ...
- 重磅消息:微信小程序支持长按二维码进入
之前微信小程序一般通过以下入口进入: 而用户经常使用“长按二维码”识别应用的功能一直未开放,据酷客多了解,微信安卓6.5.6内测版已经支持长按二维码识别和进入小程序,意味着把小程序二维码分享给朋友,或 ...
- Laravel5中通过SimpleQrCode扩展包生成二维码实例
Simple Qrcode是基于强大的Bacon/BaconQrCode库开发的针对Laravel框架的封装版本,用于在Laravel中为生成二维码提供接口. 安装SimpleQrCode扩展包 在项 ...
- jquery生成二维码图片
1.插件介绍 jquery.qrcode.min.js插件是jq系列的基于jq,在引入该插件之前要先引入jq.能够在客户端生成矩阵二维码QRCode 的jquery插件 ,使用它可以很方便的在页面上生 ...
- QrCode C#生成二维码 及JavaScript生成二维码
一 C#的二维码 示例: class Program { static void Main(string[] args) { QrEncoder qrEncoder = new QrEncode ...
- 很多人很想知道怎么扫一扫二维码就能打开网站,就能添加联系人,就能链接wifi,今天说下这些格式,明天做个demo
有些功能部分手机不能使用,网站,通讯录,wifi基本上每个手机都可以使用. 在看之前你可以扫一扫下面几个二维码先看看效果: 1.二维码生成 网址 (URL) 包含网址的 二维码生成 是大家平时最常接触 ...
- 分享2个网址二维码API接口
分享2个网址二维码生成API接口,用它们只需要填写好网址就能自动生成二维码,分别来自与bshare和jiathis分享工具中,如您需要就把下面的二维码生成API接口复制到你需要地方. 说明:把url= ...
随机推荐
- uwsgi部署flask,flask_apscheduler任务遇到各种问题解决
背景:最近在做的全域事件项目,快要靠近尾声了,需要用到uwsgi部署至生产环境,由于之前是debug模式,运行项目也是通过命令 python manager.py runserver (manage是 ...
- CocosCreator 性能优化:DrawCall
在游戏开发中,DrawCall 作为一个非常重要的性能指标,直接影响游戏的整体性能表现. 无论是 Cocos Creator.Unity.Unreal 还是其他游戏引擎,只要说到游戏性能优化,Draw ...
- 在springboot使用jsp
在springboot配置jsp环境 在pom.xml中添加配置依赖 内容如下: <dependency> <groupId>org.springframework.boot& ...
- 初学pwn的课程第一课
pwn的攻击基础原理 我的理解是主要通过分析主文件,然后获得有用信息,通过exploit对服务器输入指定的payload数据,获取服务器的shell,就是进入服务器的终端,获取服务器的控制权,对服务器 ...
- K8S-PV和PVC
目录: emptyDir存储卷 hostPath存储卷 nfs共享存储卷 PVC和PV 生命周期 一个PV从创建到销毁的流程 静态 回收策略 NFS使用PV和PVC 动态 总结 容器磁盘上的文 ...
- 多线程问题sleep与wait
涉及到的三个方法:wait():一旦执行此方法,当前线程就进入阻塞状态,并释放同步监视器notify():一旦执行此方法,就会唤醒被wait的一个线程.如果有多个线程被wait,就唤醒优先级高:not ...
- MyBatis_01(前置知识)
1-学习思路(课程主要内容): 2-MyBatis特性 3- MyBatis下载 但是我们在使用MyBatis的时候,都是直接 "Maven导入MyBatis的jar包" (所以, ...
- linux 动态库、静态库
库:可执行的二进制代码,不可以独立执行(没有main函数入口) 库是否兼容:取决于编译器.汇编器.链接器 linux链接静态库(.a):将库中用到的函数的代码指令,写入到可执行文件中.运行时无依赖 l ...
- http 请求头 content-type 字段值
Content-type 定义了 http 请求的数据类型. 如果设置在请求头中,则定义的是请求体的数据类型: 如果设置在响应头中,则定义的是响应体的数据类型: 请求头--Request-Header ...
- PYTHON用户流失数据挖掘:建立逻辑回归、XGBOOST、随机森林、决策树、支持向量机、朴素贝叶斯和KMEANS聚类用户画像|附代码数据
原文链接:http://tecdat.cn/?p=24346 最近我们被客户要求撰写关于用户流失数据挖掘的研究报告,包括一些图形和统计输出. 在今天产品高度同质化的品牌营销阶段,企业与企业之间的竞争集 ...