mybatis 插入数据报错:Incorrect string value: ‘中文’ for column ‘recipient’ at row 1

mybatis 操作MySQL数据库

配置mybatis设置字符集

在url配置

1
String url = "jdbc:mysql://10.1.11.99:3306/test?useSSL=true&useUnicode=true&characterEncoding=utf-8";

配置xml 写入xml配置需要转义 & --> &

1
<property name="url" value="jdbc:mysql://10.1.11.99:3306/test?useSSL=true&amp;useUnicode=true&amp;characterEncoding=utf-8" />

Nginx+Typecho搭建博客系统

使用Typecho快速搭建博客系统

系统准备

  • 系统环境 Ubuntu16.04, php7, nginx 1.10.3, SQLite3

  • 安装软件

1
2
3
4
# 安装nginx, php
apt install nginx php
# 安装php的 sqlite及 curl
apt install php7.0-sqlite3 php7.0-curl

Python查找类似于123-45-67+89 = 100的组合的性能分析

今天在微信公众号Python小屋看到Python查找所有类似于123-45-67+89 = 100的组合这篇文章,很感兴趣就手敲了一遍

点开链接就可以看到原文,这里就描述一下问题

在123456789这9个数字中间插入任意多个+和-的组合,使得表达式的值为100,输出所有符合条件的表达式。

第一版-排列组合

对九个数字的八个插入位置进行组合,通过对不同个数插入位,使用排列出计算所有可以出现的运算符

  • 代码如下
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from itertools import combinations, permutations
def getTotal(digits='123456789', total=100):
    # 暴力测试100的组合 使用 permutations组合构建运算符
    for i in range(1, len(digits)):
        for cut in combinations(range(1, len(digits)), i):
            cutindex = 0
            d = []
            for c in cut:
                d.append(digits[cutindex:c])
                cutindex = c
            for op in set(permutations('+-'*i, i)):
                exp = ''.join((ds+o for ds,o in zip(d, op)))+digits[c:]
                if eval(exp)== total:
                    print(exp, '=', total)

'''结果
原始排列组合用set时
123-45-67+89 = 100
123+4-5+67-89 = 100
123+45-67+8-9 = 100
1+2+34-5+67-8+9 = 100
1+23-4+5+6+78-9 = 100
1+23-4+56+7+8+9 = 100
12+3+4+5-6-7+89 = 100
12-3-4+5-6+7+89 = 100
12+3-4+5+67+8+9 = 100
123-4-5-6-7+8-9 = 100
1+2+3-4+5+6+78+9 = 100
Use Time  45.39615345001221
'''