# -*- coding: utf-8 -*-
# !/usr/bin/python3
__author__
=
'beimenchuixue'
__blog__
=
'http://www.cnblogs.com/2bjiujiu/'
def
check_str(value):
# 檢查你輸入的是否是字符類型
if
isinstance
(value,
str
):
# 判斷字符串以什么結(jié)尾
if
value.endswith(
'.sh'
):
return
'%s 是以.sh結(jié)尾的字符串'
%
value
# 判斷字符串以什么開(kāi)頭
elif
value.startswith(
'xi'
):
return
'%s 是以xi開(kāi)頭的字符串'
%
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()