参考博客
https://blog.csdn.net/cunchi4221/article/details/107475684
website = "JournalDev.com"
def return_website():
return website
print(f'My favorite website is {return_website()}')
结果如下:
# 测试案例2
website = "JournalDev.com"
def print_website():
global website
print(f'My favorite website is {website}')
website = 'Wikipedia.com'
print(f'My favorite website is {website}')
print_website()
测试案例3
结果如下
pythotn的做法如下
cnt=-1
def f():
global cnt
cnt=cnt+1
f()
print(cnt)
测试结果如下
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)