グローバル変数とローカル変数で同じ名前の変数を使うことができる。
例
x = 10
def myfunc():
x = 20
print('関数内: x = '+str(x))
myfunc()
print('外側: x = ' + str(x))
結果
関数内: x = 20 外側: x = 10
雑記
投稿日:2020年12月4日 更新日:
グローバル変数とローカル変数で同じ名前の変数を使うことができる。
x = 10
def myfunc():
x = 20
print('関数内: x = '+str(x))
myfunc()
print('外側: x = ' + str(x))
関数内: x = 20 外側: x = 10
執筆者:seyanen
関連記事
axhline, axvline を使ってx,y軸に平行な線を描くことができる。 https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot …
matplotlib の ax でx軸、y軸の端の値を設定する
axes には、set_xlim として定義する。 例 import numpy as np from matplotlib import pyplot as plt x = np.linspace( …
matplotlib で、グラフのタイトルに上付き文字を入力する方法
数学記号などで、グラフのタイトルに上付きの文字を入力したい場合がある。 その場合は次のように書いて設定できる。 例 import numpy as np from matplotlib import …
matplotlib でグラフ表示ウィンドウの画面上の位置を自由に設定する方法
matplotlib.use(‘TkAgg’) としておき、 get_current_fig_manager().window.wm_geometry(“+20+50”) として、(+20+50)のと …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。