当前位置:网站首页>实例043:作用域、类的方法与变量
实例043:作用域、类的方法与变量
2022-08-10 02:01:00 【懒笑翻】
题目:模仿静态变量(static)另一案例。
程序分析:综合实例041和实例042。
一、代码
class dummy:
num = 1
def Num(self):
print('class dummy num:', self.num)
print('global num: ', num)
self.num += 1
n = dummy()
num = 1
for i in range(5):
num *= 10
print('num---',num)
n.Num()
补充:看起来报错了,运行不会,relax!
二、运行结果
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓懒笑翻诚邀您点击下方一起来学习讨论↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
边栏推荐
猜你喜欢
随机推荐
Anchor_generators.py analysis of MMDetection framework
《GB39707-2020》PDF下载
what is a microcontroller or mcu
flask增删改查
别再用 offset 和 limit 分页了,性能太差!
按钮倒计时提醒
【Kali安全渗透测试实践教程】第6章 密码攻击
Button countdown reminder
C# 单例模式
The 25th day of the special assault version of the sword offer
MySQL:日志系统介绍 | 错误日志 | 查询日志 | 二进制日志:bin-log数据恢复实践 | 慢日志查询
中英文互译在线翻译-在线翻译软件
【二叉树-困难】124. 二叉树中的最大路径和
Will signal with different start time alignment
翻译工具-翻译工具下载批量自动一键翻译免费
ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library
深度学习(五) CNN卷积神经网络
P1564 Worship
GDB之指令基础参数
Introduction and application of quantitative trading strategies