首页 > 编程语言 > 详细

python学习:函数传参数

时间:2017-09-13 18:22:40      阅读:305      评论:0      收藏:0      [点我收藏+]
#!/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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!