python的代码检查
#!/bin/python3.4
# coding=utf-8 class lexicon(object):
# direction = ['north', 'south', 'east', 'west']
# verb = ['go', 'stop', 'kill', 'eat']
# noun = ['door', 'bear', 'princess', 'cabinet']
# num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
# wordtypelist = [direction, verb, noun, num]
def __init__(self, name):
self.name = name
print "Class name is %s." %self.name def scan(elements):
direction = ['north', 'south', 'east', 'west']
verb = ['go', 'stop', 'kill', 'eat']
noun = ['door', 'bear', 'princess', 'cabinet']
num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
wordtypelist = [direction, verb, noun, num] elements = raw_input(">> ")
element = elements.split()
for i in range(len(elements)):
count = i
if element in wordtypelist[0]:
print("num: %d type: %s element: %s" % (count, wordtypelist[0], element))
elif element in wordtypelist[1]:
print("num: %d type: %s element: %s" % (count, wordtypelist[1], element))
elif element in wordtypelist[2]:
print("num: %d type: %s element: %s" % (count, wordtypelist[2], element))
else:
print("num: %d type: %s element: %s" % (count, wordtypelist[3], element)) if __name__ == '__main__':
print("##### Start #####")
stuff = lexicon("lexicon")
stuff.scan()
print("##### End #####")
#!/bin/python3.4
# coding=utf-8 class lexicon(object):
# direction = ['north', 'south', 'east', 'west']
# verb = ['go', 'stop', 'kill', 'eat']
# noun = ['door', 'bear', 'princess', 'cabinet']
# num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
# wordtypelist = [direction, verb, noun, num]
def __init__(self, name):
self.name = name
print "Class name is %s." %self.name def scan(elements):
direction = ['north', 'south', 'east', 'west']
verb = ['go', 'stop', 'kill', 'eat']
noun = ['door', 'bear', 'princess', 'cabinet']
num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
wordtypelist = [direction, verb, noun, num] elements = raw_input(">> ")
element = elements.split()
for i in range(len(elements)):
count = i
if element in wordtypelist[0]:
print("num: %d type: %s element: %s" % (count, wordtypelist[0], element))
elif element in wordtypelist[1]:
print("num: %d type: %s element: %s" % (count, wordtypelist[1], element))
elif element in wordtypelist[2]:
print("num: %d type: %s element: %s" % (count, wordtypelist[2], element))
else:
print("num: %d type: %s element: %s" % (count, wordtypelist[3], element)) if __name__ == '__main__':
print("##### Start #####")
stuff = lexicon("lexicon")
stuff.scan()
print("##### End #####") 执行结果:
[root@localhost conwayGame.py]# python ex48.py
##### Start #####
Class name is lexicon.
>> eat the python
num: 0 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 1 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 2 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 3 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 4 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 5 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 6 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 7 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 8 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 9 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 10 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 11 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 12 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
num: 13 type: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0] element: ['eat', 'the', 'python']
##### End #####
python的代码检查的更多相关文章
- Python静态代码检查工具Flake8
简介 Flake8 是由Python官方发布的一款辅助检测Python代码是否规范的工具,相对于目前热度比较高的Pylint来说,Flake8检查规则灵活,支持集成额外插件,扩展性强.Flake8是对 ...
- Python 编写代码 检查是否遵循PEP 8标准
实际上并非必须遵守PEP 8,但是它已经成为一个默认的.约定俗成的规则,可以使代码风格更统一,提高可读性. 由于最近一直在学习Ubuntu,因此此处仍然以Ubuntu为例,介绍一下规则检查工具,它能帮 ...
- python代码检查工具(静态代码审查)
python静态代码检查 我们知道python是一门脚本语言,不像C#/Java等编译型语言可以在编译阶段就报出代码错误,脚本语言往往需要在运行期执行到这段代码时才会抛出代码错误. 那么在实际商业项目 ...
- python flake8 代码扫描
一.介绍 Flake8 是由Python官方发布的一款辅助检测Python代码是否规范的工具,flake8是下面三个工具的封装: PyFlakes Pep8 NedBatchelder's McCab ...
- python代码检查工具pylint 让你的python更规范
1.pylint是什么? Pylint 是一个 Python 代码分析工具,它分析 Python 代码中的错误,查找不符合代码风格标准(Pylint 默认使用的代码风格是 PEP 8,具体信息,请参阅 ...
- uiautomatorviewer 优化定位符生成,支持生成Java,Python自动化代码
项目介绍 二次开发 uiautomatorviewer 优化定位符生成,支持生成Java,Python自动化代码,修复自带工具画面有动态加载时截图失败问题,优化自带工具截图速度 ,实现类似录制脚本功能 ...
- WorldCount代码检查与优化——软件测试第三次作业
合作者:201631062222,201631062232 代码地址:https://gitee.com/biubiubiuLYQ/ceshi_secend 本次作业链接地址:https://edu. ...
- 使用NodeJsScan扫描nodejs代码检查安全性
使用NodeJsScan扫描nodejs代码检查安全性1.下载源码:https://github.com/ajinabraham/NodeJsScan2.下载Windows版docker toolbo ...
- Python 加入类型检查
Python 是一门强类型的动态语言, 对于一个 Python 函数或者方法, 无需声明形参及返回值的数据类型, 在程序的执行的过程中, Python 解释器也不会对输入参数做任何的类型检查, 如果程 ...
随机推荐
- 《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #20 使用fio进行I/O的基准测试
HACK #20 使用fio进行I/O的基准测试 本节介绍使用fio进行模拟各种情况的I/O基准测试的操作方法.I/O的基准测试中有无数需要考虑的因素.是I/O依次访问还是随机访问?是通过read/w ...
- 使用for...of 优点,代替for...in,forEach和for循环
来自阮一峰ES6标准: http://es6.ruanyifeng.com/#docs/iterator
- Python 之 cas-clinet
因为要搞一个用户登录安全的验证,要用到cas服务,所以在网上搜了很多关于cas信息才搞成功. 我写的属于客户端的cas就是从CAS服务,获取返回的ticket验证通过,用户登录成功. 使用的是web. ...
- canvas学习笔记、小函数整理
http://bbs.csdn.net/topics/391493648 canvas实例分享 2016-3-16 http://bbs.csdn.net/topics/390582151 html5 ...
- 0_Simple__template
简单的 CUDA 应用模板,白送的 Sample. ▶ 源代码 //template_cpu.cpp extern "C" void computeGold(float *, co ...
- HTML5 Canvas ( 线段端点的样式 ) lineCap
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 视频地址blog加密
/* JS部分 没处理兼容什么的 */ var id='<?php echo $_GET['id'];?>'; var video = document.getElementById(&q ...
- 17.在Action获取Scope对象
转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 引言:在前面的Action操作中,关键就是Action中的exectue方法 ...
- ajax方式表单拦截
html <!DOCTYPE html> <html> <head> <title></title> <meta charset=&q ...
- jquery实现背景图片动态适应
背景 在我的一个项目中用到了背景图片,发现其中有一个问题,当页面长度动态变化时,原来能占满全部内容背景的图片会变得不能占满全部背景.如下图的效果: 这是正常的,背景图片占满全屏 当页面内容变长出现了滚 ...