#!/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 解释器也不会对输入参数做任何的类型检查, 如果程 ...
随机推荐
-
Mosquitto搭建Android推送服务(三)Mosquitto集群搭建
文章钢要: 1.进行双服务器搭建 2.进行多服务器搭建 一.Mosquitto的分布式集群部署 如果需要做并发量很大的时候就需要考虑做集群处理,但是我在查找资料的时候发现并不多,所以整理了一下,搭建简 ...
-
common.support.percent.PercentFrameLayout.onLayout(PercentFrameLayout.java:151)
08-29 20:01:47.402 18908-19364/com.tongyan.subway.inspect E/CrashHandler: java.lang.NullPointerExcep ...
-
C语言 数组之无限循环
#include<stdio.h> #include<stdlib.h> #include<Windows.h> //定于数组的大小 #define N 10 vo ...
-
运行yum报错Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
今天给Centos通过rpm -Uvh装了个epel的扩展后,执行yum就开始报错: Error: Cannot retrieve metalink for repository: epel. Ple ...
-
HTML 5:绘制旋转的太极图
HTML: <!DOCTYPE> <html> <head> <meta charset="utf-8" /> <title& ...
-
Makefile中的wildcard和patsubst
makefile 里的函数跟它的变量很相似——使用的时候,你用一个 $ 符号跟开括号,函数名,空格后跟一列由逗号分隔的参数,最后用关括号结束. 例如,在 GNU Make 里有一个叫 'wild ...
-
在 Ubuntu 12.04 上安装 GitLab7.x
安装环境: 操作系统: Ubuntu 12.4 LTS 英文 数据库: postgresql webserver: nginx 能够说到7.x的时候,GitLab的文档已经相当完好 ...
-
android内置存储器memory和第三方外部存储disk管理
缓存管理这里 http://blog.csdn.net/intbird/article/details/38338713 图片处理在这里 http://blog.csdn.net/intbird/ar ...
-
最全js 放大镜效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
-
修改MacBook Pro主机名,共享电脑名
https://support.apple.com/kb/PH25384?viewlocale=zh_CN&locale=zh_CN http://www.ituring.com.cn/art ...