Python 全栈 + AI 人工智能 + 大数据分析
  • Python 全栈 + AI 人工智能 + 大数据分析
  • Python 介绍
  • Python 安装
  • 变量
  • 运算符
  • 流程控制语句
  • 数据类型
  • 函数
  • 文件
    • 字符编码
  • 模块
  • 编码
  • 面向对象编程
  • 迭代器 & 生成器
  • 装饰器
  • 处理进程
  • 网络编程 _ 概念
  • 创建可执行文件
  • 正则表达式
  • Pycharam
  • Django
  • 数据结构
  • 全网最新可用接码打码接码平台
Powered by GitBook
On this page
  • 变量命名规则
  • 变量名命名约定
  • 变量特性ls -al
  • 定义变量
  • 销毁变量
  • 注释
  • 引用赋值

Was this helpful?

变量

变量命名规则

  • 字母、数字和下划线组成且不能以数字开头

  • 区分大小写

  • 不能使用python关键字和保留字

    • 关键字:and,as,assort,break, class, continue,def, del,elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while, with, yield

变量名命名约定

  • 定义变量名有意义

  • 驼峰式命名和下划线分割单词

  • 全部大写的变量名来代表常量

变量特性ls -al

  • python 不区分变量和常量,都是变量

  • Python 的变量都是可变的

定义变量

  • 单引号定义: msg='hello'

  • 双引号定义: msg="hello"

  • 三个单引号定义

msg='''
hello
world'''
  • 三个双引号定义

msg="""
hello
world"""

销毁变量

  • del 变量名

  • age = nil

注释

注释用于增强程序源代码可读性

# 单行注释

'''
多行注释
'''`

"""
多行注释
"""

引用赋值

num = [10]
num += 10 # 引用地址的值修改
print(id(num))
num = num + 10 # 使用新的内存空间
print(id(num))
PreviousPython 安装Next运算符

Last updated 5 years ago

Was this helpful?