随笔分类 -  Python3

摘要:yaml test.yaml文件: name: Tom Smith age: 37 spouse: name: Jane Smith age: 25 children: name: Jimmy Smith age: 15 name1: Jenny Smith age1: 12 python文件: i 阅读全文
posted @ 2019-12-13 16:48 Le1B_o 阅读(736) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-12-11 14:02 Le1B_o 阅读(261) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-11-20 16:01 Le1B_o 阅读(564) 评论(0) 推荐(0)
摘要:本文以csr_matrix为例来说明sparse矩阵的使用方法,其他类型的sparse矩阵可以参考https://docs.scipy.org/doc/scipy/reference/sparse.html csr_matrix是Compressed Sparse Row matrix的缩写组合,下 阅读全文
posted @ 2019-11-20 14:47 Le1B_o 阅读(1641) 评论(0) 推荐(0)
摘要:xml模块 处理文档: import xml.etree.ElementTree as ET tree = ET.parse('xmlfile') ET.parse() 解析xml文档 root = tree.getroot() 获取根节点 print(root.tag) root.tag 获取根节 阅读全文
posted @ 2019-11-19 19:38 Le1B_o 阅读(172) 评论(0) 推荐(0)
摘要:写在前面:当遇到一个陌生的python第三方库时,可以去pypi这个主页查看描述以迅速入门! 或者import timedir(time) easydict的作用:可以使得以属性的方式去访问字典的值!>>> from easydict import EasyDict as edic 阅读全文
posted @ 2019-10-24 22:39 Le1B_o 阅读(735) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/u014745194/article/details/70176117 ! flowchart 箭头图标 勿删 Python中生成器和迭代器的区别(代码在Python3.5下测试): Num01–>迭代器 定义: 对于list、string、tup 阅读全文
posted @ 2019-04-03 16:56 Le1B_o 阅读(194) 评论(0) 推荐(0)
摘要:转自:https://blog.ixxoo.me/argparse.html 原文:Argparse Tutorial 译者:likebeta 本教程是对于Python标准库中推荐使用的命令行解析模块argparse的简单介绍。 PS:还有其他两个模块实现这一功能,getopt(等同于C语言中的ge 阅读全文
posted @ 2019-03-24 22:08 Le1B_o 阅读(299) 评论(0) 推荐(0)
摘要:我们经常在python的模块目录中会看到 "__init__.py"  这个文件,那么它到底有什么作用呢?   1. 标识该目录是一个python的模块包(module package) 如果你是使用python的相关IDE来进行开发,那么如果目录中存在该文件,该目录就会被识别为 阅读全文
posted @ 2019-03-07 15:56 Le1B_o 阅读(299) 评论(0) 推荐(0)
摘要:import os print ' 获取当前目录 ' print os.getcwd() print os.path.abspath(os.path.dirname(__file__)) print ' 获取上级目录 ' print os.path.abspath(os.path.dirname(o 阅读全文
posted @ 2019-03-06 15:00 Le1B_o 阅读(9582) 评论(0) 推荐(1)
摘要:注:sys.path模块是动态的修改系统路径 模块要处于Python搜索路径中的目录里才能被导入,但我们不喜欢维护一个永久性的大目录,因为其他所有的Python脚本和应用程序导入模块的时候性能都会被拖累。本节代码动态地在该路径中添加了一个"目录",当然前提是此目录存在而且此前不在sys.path中。 阅读全文
posted @ 2019-03-05 11:44 Le1B_o 阅读(1129) 评论(0) 推荐(0)
摘要:class FooParent(object): def __init__(self): self.parent = 'I\'m the parent.' print ('Parent') def bar(self,message): print ("%s from Parent" % messag 阅读全文
posted @ 2018-12-06 22:10 Le1B_o 阅读(135) 评论(0) 推荐(0)