1,占位符%s %d name="我是%s,年龄%d,爱好%s"%("小飞侠",18,"打豆豆") print(name) 2,中文转gbk编码 s='编号:100566' a=s.encode('gbk') print(a) #输出b'\xb1\xe0\xba\xc5\xa3\xba100566' ...
分类:
编程语言 时间:
2020-02-19 19:15:29
阅读次数:
85
Largest palindrome product A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 digit numbers is 9009 ...
分类:
其他好文 时间:
2020-02-17 18:15:39
阅读次数:
102
1. 连接数据库 import redis class RedisTest(object): def __init__(self): self.client = redis.StrictRedis(host="xx",port=xx,password="xx",db=0,decode_respons ...
分类:
编程语言 时间:
2020-02-17 18:02:19
阅读次数:
80
代码块: python真正的代码块:一个模块,一个函数,一个类,一个文件等都是一个代码块。 但是,在python终端交互模式下,每一条代码都是一个代码块 python在同一个代码块中的变量,初始化对象的命令时,它会将变量与值的对应关系放到一个字典中, 如果下面的代码在遇到初始化对象的命令,他会先从字 ...
分类:
编程语言 时间:
2020-02-16 14:43:25
阅读次数:
76
经常有这种需求,如当数据库里的状态为20100时,中文希望显示为办理成功,这个时候就需要条件判断了 Oracle中条件判断有三种,如下将分别介绍 一、case ... when ... then ... else ... end【相当于大于小于等于不等于判断】 语法介绍 示例 二、decode(co ...
分类:
数据库 时间:
2020-02-14 22:38:49
阅读次数:
185
pyhon读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xe9 in position 7581: illegal multibyte sequence 代码如下: #获取电影列表 def getMovieList(item): ...
分类:
其他好文 时间:
2020-02-14 01:03:46
阅读次数:
67
一.Huffman树 定义: 给定n个权值作为n个叶子结点,构造一棵二叉树,若该树的带权路径达到最小,这样的二叉树称为最优二叉树,也称为霍夫曼树(Huffman树). 特点: Huffman树是带权路径长度最短的树,权值较大的节点离根节点较近 权值 = 当前节点的值 * 层数,wpl最小的值,就是H ...
分类:
其他好文 时间:
2020-02-13 16:32:33
阅读次数:
104
在python2默认编码是ASCII ,python3里默认是unicode 1 #__author__ = 'Shuaihu Mu' 2 3 import sys 4 print(sys.getdefaultencoding()) 5 6 s = '大家好' #这个是默认的Unicode 7 pr ...
分类:
其他好文 时间:
2020-02-13 15:19:25
阅读次数:
91
``` import demjson s = """ {'weibo_account': '{"province":"\\u65b0\\u7586","city":"\\u5854\\u57ce","gender":"\\u7537"}'} """ # b =s.encode('ascii').de... ...
分类:
Web程序 时间:
2020-02-13 14:33:28
阅读次数:
96
爬楼梯。题意是给一个数字n代表楼梯的高度,你可以每次爬一步或者两步,求有多少种不同的爬法。例子, Example 1: Input: 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step ...
分类:
其他好文 时间:
2020-02-13 09:56:32
阅读次数:
70