global使用和不使用的情况总结

简介: global使用和不使用的情况总结

1. 使用global:

改变变量所指向内容

# 数字变量变化
i = 1
def fun():
  global i
  i += 1

l = [0]
# 容器通过加法扩展
def fun():
  global l
  l += [1]

2. 不使用global:

不改变变量所指向内容,只改变内容

l = [0]
# 容器内元素变化
def fun():
  l[0] += 1

# 容器通过append扩展
def fun():
  l.append(1)
目录
相关文章
|
5天前
|
Python
global
global
19 1
|
5天前
|
JavaScript
npm报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
17 1
|
5天前
|
JavaScript
报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
|
5天前
|
安全 容灾 网络安全
Global Accelerator
在现代社会,网络速度和稳定性对我们的生活和工作越来越重要。阿里云全球加速GA(Global Accelerator)应运而生,它是一款覆盖全球的互联网加速服务,通过智能调度网络传输流量、优化传输层协议、全局智能选路等方法,实现网络加速,大幅提高网络传输的稳定性和性能。
26 1
|
关系型数据库 MySQL 数据库
MySQL - 查看 / 修改配置参数(Global Variables)
MySQL - 查看 / 修改配置参数(Global Variables)
784 0
MGA (Managed Global Area) Reference Note (Doc ID 2638904.1)
MGA (Managed Global Area) Reference Note (Doc ID 2638904.1)
227 0
All cached global options setting for WordPress
All cached global options setting for WordPress
71 0
All cached global options setting for WordPress
Global variable in ABAP function group
Global variable in ABAP function group
148 0
Global variable in ABAP function group
成功解决Instructions for updating: Use `tf.global_variables_initializer` instead.
成功解决Instructions for updating: Use `tf.global_variables_initializer` instead.
|
安全
Error Code: 1175. You are using safe update mode and you tried to update a t
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/79677217 在安全模式下,只能根据主键来做修改,所以使用非主键修改,那么将要解除安全模式,然后再执行操作。
1612 0