#!/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的代码检查的更多相关文章

  1. Python静态代码检查工具Flake8

    简介 Flake8 是由Python官方发布的一款辅助检测Python代码是否规范的工具,相对于目前热度比较高的Pylint来说,Flake8检查规则灵活,支持集成额外插件,扩展性强.Flake8是对 ...

  2. Python 编写代码 检查是否遵循PEP 8标准

    实际上并非必须遵守PEP 8,但是它已经成为一个默认的.约定俗成的规则,可以使代码风格更统一,提高可读性. 由于最近一直在学习Ubuntu,因此此处仍然以Ubuntu为例,介绍一下规则检查工具,它能帮 ...

  3. python代码检查工具(静态代码审查)

    python静态代码检查 我们知道python是一门脚本语言,不像C#/Java等编译型语言可以在编译阶段就报出代码错误,脚本语言往往需要在运行期执行到这段代码时才会抛出代码错误. 那么在实际商业项目 ...

  4. python flake8 代码扫描

    一.介绍 Flake8 是由Python官方发布的一款辅助检测Python代码是否规范的工具,flake8是下面三个工具的封装: PyFlakes Pep8 NedBatchelder's McCab ...

  5. python代码检查工具pylint 让你的python更规范

    1.pylint是什么? Pylint 是一个 Python 代码分析工具,它分析 Python 代码中的错误,查找不符合代码风格标准(Pylint 默认使用的代码风格是 PEP 8,具体信息,请参阅 ...

  6. uiautomatorviewer 优化定位符生成,支持生成Java,Python自动化代码

    项目介绍 二次开发 uiautomatorviewer 优化定位符生成,支持生成Java,Python自动化代码,修复自带工具画面有动态加载时截图失败问题,优化自带工具截图速度 ,实现类似录制脚本功能 ...

  7. WorldCount代码检查与优化——软件测试第三次作业

    合作者:201631062222,201631062232 代码地址:https://gitee.com/biubiubiuLYQ/ceshi_secend 本次作业链接地址:https://edu. ...

  8. 使用NodeJsScan扫描nodejs代码检查安全性

    使用NodeJsScan扫描nodejs代码检查安全性1.下载源码:https://github.com/ajinabraham/NodeJsScan2.下载Windows版docker toolbo ...

  9. Python 加入类型检查

    Python 是一门强类型的动态语言, 对于一个 Python 函数或者方法, 无需声明形参及返回值的数据类型, 在程序的执行的过程中, Python 解释器也不会对输入参数做任何的类型检查, 如果程 ...

随机推荐

  1. pythone--002

    元组就是不可修改: 字典的索引不是自增的.  元组和列表是: 默认 是key 通过get  没有这个key  是none get可以有默认值: 通过索引 没有就报错. 检查字典中某个可以是否存在:ha ...

  2. CentOS 7.4 安装部署 iRedMail 邮件服务器

    在公司部署了一套开源的邮件网关Scrollout F1用来测试,由于Scrollout F1需要使用IMAP协议连接到邮件服务器上的隔离邮箱,抓取GOOD和BAD文件夹里的邮件进行贝叶斯学习,但公司的 ...

  3. zabbix监控windows磁盘空间

    监控windows磁盘空间,不是百分比. 当windows系统添加相应的windows模板后,会自动生成检测系统空间的监控项,在应用集(Filessystem)里面,Free disk space o ...

  4. leetcode27

    public class Solution { public int RemoveElement(int[] nums, int val) { var len = nums.Length; ; ; i ...

  5. LiveBinding应用 dataBind 数据绑定

    http://blog.csdn.net/embarcaderochina/article/details/50352193 firemonkey grid/listview dataBind,数据绑 ...

  6. VB6 MsgBox 函数

    在对话框中显示消息,等待用户单击按钮,并返回一个值指示用户单击的按钮. MsgBox(prompt[, buttons][, title][, helpfile, context]) 参数 promp ...

  7. gradle问题 cordova

    cordova升级7.0后,运行 > ionic build android  或者 cordova build android     报出错误 Error: Could not find a ...

  8. 前端-javascript-BOM-浏览器对象模型

    BOM的介绍---浏览器对象模型. 操作浏览器部分功能的API.比如让浏览器自动滚动. -------------------------------------------------------- ...

  9. Qt 软件的发布

    我们程序的Release版本正式发布需要将各种依赖的库文件一起打包. 有时候我们并不清楚具体依赖哪些库,这时,可以用Qt的一个工具"windeployqt" 比如,找到程序.exe ...

  10. JAVA WEB开发中的资源国际化

    为什么要国际化? 不同国家与地区语言,文化,生活习惯等差异.在数字,时间,语言,货币,日期,百分数等的不同. 两个名词: I18N:即资源国际化,全称为Internationalization,因为首 ...