随笔分类 -  Python

摘要:1,使用parse_log.sh工具 解析出来train,和test两个工具 plot_training_log.py工具不可以使用,于是使用自己写的脚本工具进行处理 2,由于提取的文件都是以空格隔开,读入到计算机中是一个维的数据,所以用命令来更新文件 写一个sh脚本displace.sh #!/b 阅读全文
posted @ 2018-05-15 20:47 真勇士王小山 阅读(136) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/lenovojxn/article/details/53768537(好。。。) https://www.cnblogs.com/xiaoxuebiye/articles/7071418.html (全。。。。) 阅读全文
posted @ 2018-05-05 19:23 真勇士王小山 阅读(5910) 评论(0) 推荐(0) 编辑
摘要:import scipy.io data = scipy.io.loadmat('1.mat') # 假设文件名为1.mat # data类型为dictionary print data.keys() # 即可知道Mat文件中存在数据名,假设存在'x', 'y'两列数据 print data['x' 阅读全文
posted @ 2018-05-04 20:21 真勇士王小山 阅读(198) 评论(0) 推荐(0) 编辑
摘要:一,图像的基础操作 1,获取并修改像素值 获取(速度比较慢) px=img[100,100]print pxblue=img[100,100,0]print blue 修改 img[100,100]=[255,255,255]print img[100,100] 另一种更好的方法(使用numpy)速 阅读全文
posted @ 2018-04-25 11:26 真勇士王小山 阅读(223) 评论(0) 推荐(0) 编辑
摘要:1,读入图像 import numpy as npimport cv2img = cv2.imread('messi5.jpg',0) 0:cv2.IMREAD_GRAYSCALE:以灰度模式读入图像 1:cv2.IMREAD_COLOR:读入一副彩色图像。图像的透明度会被忽略,这是默认参数 cv2 阅读全文
posted @ 2018-04-24 20:10 真勇士王小山 阅读(1050) 评论(0) 推荐(0) 编辑
摘要:== python 相关 == https://www.shiyanlou.com/courses/596 http://www.ncnynl.com/archives/201610/992.html 例子 helloworld.py #!/usr/bin/env python print("Hel 阅读全文
posted @ 2018-02-08 10:52 真勇士王小山 阅读(129) 评论(0) 推荐(0) 编辑
摘要:软件开发的过程 现在,我们已经走过了编写一个软件的各个环节。这些环节可以概括如下: 重要我们创建这个备份脚本的过程是编写程序的推荐方法——进行分析与设计。开始时实施一个简单的版本。对它进行测试与调试。使用它以确信它如预期那样地工作。再增加任何你想要的特性,根据需要一次次重复这个编写-测试-使用的周期 阅读全文
posted @ 2017-10-20 10:50 真勇士王小山 阅读(2226) 评论(0) 推荐(0) 编辑
摘要:exec语句用来执行储存在字符串或文件中的Python语句。例如,我们可以在运行时生成一个包含Python代码的字符串,然后使用exec语句执行这些语句。下面是一个简单的例子。 >>> exec 'print "Hello World"'Hello World eval语句用来计算存储在字符串中的有 阅读全文
posted @ 2017-10-20 10:13 真勇士王小山 阅读(130) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: lambda.pydef make_repeater(n): return lambda s: s*ntwice = make_repeater(2)print twice('word')print twice(5) make_repeate 阅读全文
posted @ 2017-10-20 10:06 真勇士王小山 阅读(88) 评论(0) 推荐(0) 编辑
摘要:>>> def powersum(power, *args):... '''Return the sum of each argument raised to specified power.'''... total = 0... for i in args:... total += pow(i, 阅读全文
posted @ 2017-10-20 09:48 真勇士王小山 阅读(122) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: list_comprehension.pylistone = [2, 3, 4]listtwo = [2*i for i in listone if i > 2]print listtwo 这里我们为满足条件(if i > 2)的数指定了一个 阅读全文
posted @ 2017-10-20 09:45 真勇士王小山 阅读(99) 评论(0) 推荐(0) 编辑
摘要:os模块 这个模块包含普遍的操作系统功能。如果你希望你的程序能够与平台无关的话,这个模块是尤为重要的。即它允许一个程序在编写后不需要任何改动,也不会发生任何问题,就可以在Linux和Windows下运行。一个例子就是使用os.sep可以取代操作系统特定的路径分割符。 下面列出了一些在os模块中比较有 阅读全文
posted @ 2017-10-20 00:52 真勇士王小山 阅读(99) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: cat.pyimport sysdef readfile(filename): '''Print a file to the standard output.''' f = file(filename) while True: line = 阅读全文
posted @ 2017-10-20 00:49 真勇士王小山 阅读(268) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: finally.pyimport timetry: f = file('poem.txt') while True: # our usual file-reading idiom line = f.readline() if len(line 阅读全文
posted @ 2017-10-20 00:41 真勇士王小山 阅读(145) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: raising.pyclass ShortInputException(Exception): '''A user-defined exception class.''' def __init__(self, length, atleast) 阅读全文
posted @ 2017-10-20 00:35 真勇士王小山 阅读(158) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: try_except.pyimport systry: s = raw_input('Enter something --> ')except EOFError: print '\nWhy did you do an EOF on me?' 阅读全文
posted @ 2017-10-20 00:30 真勇士王小山 阅读(110) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: pickling.pyimport cPickle as p#import pickle as pshoplistfile = 'shoplist.data'# the name of the file where we will store 阅读全文
posted @ 2017-10-19 00:57 真勇士王小山 阅读(159) 评论(0) 推荐(0) 编辑
摘要:首先,我们通过指明我们希望打开的文件和模式来创建一个file类的实例。模式可以为读模式('r')、写模式('w')或追加模式('a')。事实上还有多得多的模式可以使用,你可以使用help(file)来了解它们的详情。 我们首先用写模式打开文件,然后使用file类的write方法来写文件,最后我们用c 阅读全文
posted @ 2017-10-19 00:29 真勇士王小山 阅读(120) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: inherit.pyclass SchoolMember: '''Represents any school member.''' def __init__(self, name, age): self.name = name self.ag 阅读全文
posted @ 2017-10-19 00:21 真勇士王小山 阅读(98) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python# Filename: objvar.pyclass Person: '''Represents a person.''' population = 0 def __init__(self, name): '''Initializes the person's da 阅读全文
posted @ 2017-10-19 00:16 真勇士王小山 阅读(140) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示