# -*- coding: utf-8 -*-
# !/usr/bin/python3
__author__
=
'beimenchuixue'
__blog__
=
'http://www.cnblogs.com/2bjiujiu/'
def
check_str(value):
# 检查你输入的是否是字符类型
if
isinstance
(value,
str
):
# 判断字符串以什么结尾
if
value.endswith(
'.sh'
):
return
'%s 是以.sh结尾的字符串'
%
value
# 判断字符串以什么开头
elif
value.startswith(
'xi'
):
return
'%s 是以xi开头的字符串'
%
value
else
:
return
'%s 不满足以上条件的字符串'
%
value
else
:
return
'%s is not str'
%
value
def
main():
str_one
=
'bei_men.sh'
resp_one
=
check_str(str_one)
print
(resp_one)
str_two
=
'xi_du.py'
resp_two
=
check_str(str_two)
print
(resp_two)
str_three
=
233
resp_three
=
check_str(str_three)
print
(resp_three)
if
__name__
=
=
'__main__'
:
main()