随笔分类 -  python 零散知识

学到哪儿记到哪儿
pypi 国内源
摘要:python install 的时候选择国内源 pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple 或者单独一个包 pip install somepackage -i https://pypi.tu 阅读全文

posted @ 2020-03-11 21:30 chungehpu 阅读(210) 评论(0) 推荐(0)

DB-Lib error message 20002, severity 9
摘要:完整报错内容:20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (I0.185.43.12:1433)\n' 问题描述 :在python中,使用 psmssql 连接远程数据库,报上 阅读全文

posted @ 2019-09-10 21:42 chungehpu 阅读(12809) 评论(6) 推荐(4)

open的正确使用
摘要:open一个对象的时候,不确定他是图片还是文本啊 # import io with open('photo.jpg', 'rb') as inf: jpgdata = inf.read() if jpgdata.startswith(b'\xff\xd8'): text = u'This is a 阅读全文

posted @ 2018-01-07 16:50 chungehpu 阅读(184) 评论(0) 推荐(0)

代码这样写不止于优雅(2)
摘要: 阅读全文

posted @ 2018-01-07 16:33 chungehpu 阅读(69) 评论(0) 推荐(0)

代码这样写不止于优雅(1)
摘要: 阅读全文

posted @ 2018-01-07 16:24 chungehpu 阅读(105) 评论(0) 推荐(0)

一些基础语法
摘要:1.使用 \ 将一行语句分为多行显示 statement = "hello world " + \ "this is my first time of creating blog in cnblogs " + \ "I am very excited" print(statement) output 阅读全文

posted @ 2018-01-07 15:42 chungehpu 阅读(112) 评论(0) 推荐(0)

super(classname,self).__init__() 作用
摘要: 阅读全文

posted @ 2018-01-07 15:04 chungehpu 阅读(679) 评论(0) 推荐(0)

if __name__ = "main" 解释
摘要: 阅读全文

posted @ 2018-01-07 14:49 chungehpu 阅读(137) 评论(0) 推荐(0)

ConfigParser 模块
摘要:Python 读取写入配置文件很方便,可使用内置的 configparser 模块 该模块支持读取windows 下的 .conf 及 .ini 文件等。 [section1] option1 = "hello" option2 = "world" [section2] option3 = 111 阅读全文

posted @ 2018-01-07 14:45 chungehpu 阅读(101) 评论(0) 推荐(0)

map + filter + reduce
摘要:map 是对 集合 里面的元素一个接一个的进行某种运算,常常与lambda 结合使用 #求平方: items = [1, 2, 3, 4, 5] squared = list(map(lambda x: x**2, items)) 此外,map还可以对函数进行迭代运算: # def multiply 阅读全文

posted @ 2018-01-07 14:31 chungehpu 阅读(103) 评论(0) 推荐(0)

导航