皆さん、
今日は Python 変数について学習します。
a=1 # variable as int b="aravin" # variable as string x=5 # First assign the int value to X x='aravin' # Later assign the str value to X print(x) # o/p aravin, recently assign value to use same variable.
a=100 A='India' # a will not overwrite to A both are diff. print(a) print(A)
var=100 mvar='Hello' print(type(var))
例:
正式な名前:
my_variable_name = "アラビン" #ヘビの種類
myVariableName = "Aravin" #ラクダ型
MyVariableName = "Aravin" #パスカル型
myvarname = "アラビン"
_myvarname = "アラビン"
myvar_name = "アラビン"
myvar21 = "アラビン"
不適切な名前:
2myVar = "こんにちは"
my-var = "こんにちは"
私の変数 = "こんにちは"
a,b,c = 5,"aravin","DB"
a = b = c = "Apple"
myVar = ["var1","var2","var3"] a,b,c = myVar print(myVar) print(b)
例:
a = "python" def myfunc(): print("Hello " + a) myfunc()
a = "python" def myfunc(): a = "python" print("Hai " + a) myfunc() print("Hello " + a)
def myfunc(): global a a = "python" myfunc() print("Hello " + a)
a = "python" def myfunc(): global a a = "Python" myfunc() print("Hai " + x)
以上がPython: 変数の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。