1.常用参数解析工具
argparse #解析命令行参数
configparser #解析配置文件
json #解析配置文件
tf.app.flags #采用的是tensorflow库中自带的tf.app.flags模块实现命令行参数的解析。
#如果用终端运行tf程序,用上述两种方式都可以,如果用spyder之类的工具,那么只有argparse方式有用,
#tf.app.flags模块方式会报错。
2.常用函数
获取当前目录
os.getcwd()
参考:http://www.runoob.com/python/os-getcwd.html
xml文件解析工具
xml.etree.ElementTree
ElementTree生来就是为了处理XML,它在Python标准库中有两种实现:一种是纯Python实现的,如xml.etree.ElementTree,另一种是速度快一点的xml.etree.cElementTree。注意:尽量使用C语言实现的那种,因为它速度更快,而且消耗的内存更少。
参考:https://www.cnblogs.com/xiaobingqianrui/p/8405813.html
参考:http://www.runoob.com/python/python-func-enumerate.html
list()函数将元组转换为列表
enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中
参考:http://www.runoob.com/python3/python3-func-reversed.html
reversed() 函数返回一个反转的迭代器
strip()函数
用于移除字符串头尾指定的字符(默认为空格)。
参考:http://www.runoob.com/python3/python3-string-strip.html
split()函数
通过指定分隔符对字符串进行切片,如果参数num 有指定值,则仅分隔 num 个子字符串
参考:http://www.runoob.com/python3/python3-string-split.html
int() 函数
用于将一个字符串或数字转换为整型。
参考:http://www.runoob.com/python/python-func-int.html
numpy.save
numpy.savez
numpy.load
numpy文件存取函数,提供了多种存取数组内容的文件操作函数。保存数组数据的文件可以是二进制格式或者文本格式。二进制格式的文件又分为NumPy专用的格式化二进制类型和无格式类型。
参考:https://docs.scipy.org/doc/numpy/reference/generated/numpy.savez.html
参考:https://blog.csdn.net/pursuitbeauty/article/details/42169821
numpy产生随机数
参考:https://blog.csdn.net/jinxiaonian11/article/details/53143141
list 列表,python内置的一种数据类型是列表:list是一种有序的数据集合,可以随意的添加和删除其中的数据。
tuple 元组,和列表类似,元组也是一种有序列表,虽然tuple和list非常之类似,list初始化之后使可以改变的,但是,元组一旦初始化之后就不可以改变。
现在tuple不能变了,它也没有append(),insert()这样的方法。其他获取元素的方法和list是一样的,你可以正常地使用tuple[0],tuple[-1],但不能赋值成另外的元素。
不可变的tuple有什么意义?因为tuple不可变,所以代码更安全。如果可能,能用tuple代替list就尽量用tuple。
参考:https://blog.csdn.net/liuyanfeier/article/details/53731239