马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 一个账号 于 2020-3-7 22:32 编辑 var = 'Hi'
def fun1():
global var
var = 'Baby'
return fun2(var)
def fun2(var):
var += 'I love you'
fun3(var)
return var
def fun3(var):
var = '小甲鱼'
print(var)
print(fun1())
def hui(params):
l = len(params)
n = 0
while n < l//2:
if params[n] == params[l-n-1]:
return '这是回文联'
else:
return '不是回文联'
def hui1(params):
list1 = list(params)
list2 = reversed(list1)
print(list(list2))
if list1 == list(list2):
return '这是回文联'
else:
return '不是回文联'
params = input('请输入一句话:')
print(hui1(params))
# 回文联
def count(m):
a,b,c,d = 0,0,0,0
#l = len(m)
for n in m:
if n.isalpha():
a+=1
elif n.isdigit():
b+=1
elif n == ' ':
c+=1
else:
d+=1
return '英文%d个,数字%d个,空格%d个,其他字符%d个' % (a,b,c,d)
def countTwo(x,y):
print( '第一行:'+count(x))
print('第二行:'+count(y))
def countThird(*params):
l = len(params)
a,b,c,d = 0,0,0,0
for i in range(l):
for n in params[i]:
if n.isalpha():
a+=1
elif n.isdigit():
b+=1
elif n == ' ':
c+=1
else:
d+=1
print( '第%d行: 英文%d个,数字%d个,空格%d个,其他字符%d个' % (i+1,a,b,c,d))
print(count('i 2 lonf 5*= k@#lg '))
countTwo('hjf 55h) ','jdnj515 55g jhd*K ')
countThird('hjf 55h) ','jdnj515 55g jhd*K ')
全局变量 https://fishc.com.cn/forum.php?m ... p;page=1#pid4379822 |