012 Python约定俗称的常量

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Datatime:2022/7/18 21:13
# Filename:011 Python约定俗称的常量.py
# Toolby: PyCharm

# 变量:变化的量,可以通过各种操作改变它

# 不变的量:nick 的帅,当你定义它的时候,就定死了

height = 180

print(height)

height = 181
height = height + 1
print(height)

nick_meimaodu = 100
print(nick_meimaodu)
nick_meimaodu = nick_meimaodu + 1
print(nick_meimaodu)


# 常量:不变化的量
# 常量的定义--》常量名的字母全部大写

NICK_MEIMAODU  = 100
print(NICK_MEIMAODU)
NICK_MEIMAODU = NICK_MEIMAODU + 1


NICK_MEIMAODU = '帅'

NICK_MEIMAODU = '更帅'
print(NICK_MEIMAODU)  # 100 或者 报错

# 常量和变量由区别吗?
# 有,常量是程序猿约定俗成的

NICK_MEIMAODU  = 100

NICK_MEIMAODU = NICK_MEIMAODU+1 # 硬着头皮去修改别人,你是脑子抽风了

# 常量一般用在设置里面
posted @ 2022-07-19 22:16  B站-水论文的程序猿  阅读(261)  评论(0编辑  收藏  举报