#!/usr/bin/python
import sys
def isNum(s):
for i in s:
if i in ‘0123456789‘:
pass
else:
print "%s is not a number" %s
sys.exit()
else:
print "%s is a number" %s
isNum(sys.argv[1])
//函数判断是否为数字
执行结果:
python 12.py aa
aa is not a number
[root@web10 day02]# python 12.py 123
123 is a number
[root@web10 day02]# python 12.py 123d
123d is not a number
python学习:函数传参数
原文:http://www.cnblogs.com/weifeng1463/p/7516301.html