上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 38 下一页
摘要: import base64s_raw = "中国人a"b_raw = s_raw.encode() # S.encode(encoding='utf-8', errors='strict') -> bytesb64 = base64.b64encode(b_... 阅读全文
posted @ 2018-12-27 08:59 xuejianbest 阅读(3340) 评论(0) 推荐(0) 编辑
摘要: 异常捕获流程:try: 2.3 / 0except ValueError: print("ValueError") # 特定except,只有异常匹配时执行except ZeroDivisionError: print... 阅读全文
posted @ 2018-12-27 08:59 xuejianbest 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 排序:使用sorted方法和列表的sort方法:sorted方法适用范围更广,sort方法只有列表有。li = [{'a':'23'}, {'a':'12'}]def sort_fun(mp): s = mp['a'] return int(s)... 阅读全文
posted @ 2018-12-27 08:59 xuejianbest 阅读(2146) 评论(0) 推荐(0) 编辑
摘要: 安装:pip install ipythonpip install "ipython[notebook]" #或者pip3 install ipython[all]#用浏览器即时运行调试代码ipython notebook修改启动默认目录:jupyter ... 阅读全文
posted @ 2018-12-26 09:27 xuejianbest 阅读(1495) 评论(0) 推荐(0) 编辑
摘要: 合并段落:将以非法段落结束符结束的段落和下一段落进行合并,并去掉空白行和段落首尾的空白字符。def isEndOfP(line): notendstrs = ["www.", "文章"] for notendstr in notendstrs: ... 阅读全文
posted @ 2018-12-26 09:27 xuejianbest 阅读(1173) 评论(0) 推荐(0) 编辑
摘要: 极坐标方程:ρ=a(1−sin⁡θ)\rho = a (1-\sin\theta)ρ=a(1−sinθ)极坐标画图:%matplotlib inlineimport matplotlib.pyplot as pltimport numpy as npthet... 阅读全文
posted @ 2018-12-26 09:27 xuejianbest 阅读(2858) 评论(0) 推荐(0) 编辑
摘要: 每次调用session_maker()都会返回一个新的session对象,两次调用返回的session对象不同。在一个线程中,多次调用scoped_session()返回的session对象是一个,类似单例模式。但是在不同线程中调用scoped_sessio... 阅读全文
posted @ 2018-12-26 09:27 xuejianbest 阅读(522) 评论(0) 推荐(1) 编辑
摘要: 安装:pip install sqlalchemy# 安装数据库驱动:pip install pymysqlpip install cx_oracle举例:(在url后面加入?charset=utf8可以防止乱码)from sqlalchemy import... 阅读全文
posted @ 2018-12-26 09:27 xuejianbest 阅读(1605) 评论(0) 推荐(0) 编辑
摘要: 定义一个df:dates = pd.date_range('20180101', periods=6)df = pd.DataFrame(np.arange(24).reshape(6, 4), index=dates, columns=['A', 'B',... 阅读全文
posted @ 2018-12-26 09:27 xuejianbest 阅读(1658) 评论(0) 推荐(0) 编辑
摘要: 在ipython notebook 或 Jupyter 下使用matplotlib画图:%matplotlib inlineimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axe... 阅读全文
posted @ 2018-12-26 09:27 xuejianbest 阅读(146) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 38 下一页