“变量名称”或“变量左值”或“变量值”。 [英] "Variable variable name" or "variable lvalue"
问题描述
大家好吗
我想知道如何在python中声明一个变量名称那个
它又是一个变量
在bash shell中我会写如下:
for x in seq 1 3`
do
M $ i =材料(x)#Material是一个python类
完成
为什么我需要这个?因为我有一个python模块,迫使我构建
a变量名为Period,它应该有一个变量名称
summands(取决于x的值)
#让我们说x = 3,然后周期定义是
周期=板坯(材料1(12.5)+材料2(25)+材料3(12.5) )#Slab是一个
python类
我不知道如何自动化任何x的最后一段代码
谢谢
Marcos
Hello to everybody
I would like to know how to declare in python a "variable name" that
it is in turn a variable
In bash shell I would wrote sthg like:
for x in `seq 1 3`
do
M$i=Material(x) #Material is a python class
done
Why I need this? Cause I have a python module that obliges me to build
a variable called Period, which should have a variable name of
summands (depends on the value of x)
#Let''s say x=3, then Period definition is
Period=Slab(Material1(12.5)+Material2(25)+Material 3(12.5)) #Slab is a
python class
I dont know how to automatize last piece of code for any x
thank you
Marcos
推荐答案
i =材料(x)#Material是一个蟒蛇课
完成
为什么我需要这个?因为我有一个python模块,迫使我构建
a变量名为Period,它应该有一个变量名称
summands(取决于x的值)
#让我们说x = 3,然后周期定义是
周期=板坯(材料1(12.5)+材料2(25)+材料3(12.5) )#Slab是一个
python类
我不知道如何自动化任何x的最后一段代码
谢谢
Marcos
i=Material(x) #Material is a python class
done
Why I need this? Cause I have a python module that obliges me to build
a variable called Period, which should have a variable name of
summands (depends on the value of x)
#Let''s say x=3, then Period definition is
Period=Slab(Material1(12.5)+Material2(25)+Material 3(12.5)) #Slab is a
python class
I dont know how to automatize last piece of code for any x
thank you
Marcos
2007年8月15日星期三10:42:02 -0700, mfglinux写道:
On Wed, 15 Aug 2007 10:42:02 -0700, mfglinux wrote:
我想知道如何在python中声明一个变量名&那个
它又是一个变量
在bash shell中我会写如下:
for x in seq 1 3`
do
M
I would like to know how to declare in python a "variable name" that
it is in turn a variable
In bash shell I would wrote sthg like:
for x in `seq 1 3`
do
M
i =材料(x)#Material是一个python类
完成
i=Material(x) #Material is a python class
done
你想要一本字典。
M = dict()
for x在xrange(1,4):
M [x] =材料(x)
Ciao,
Marc'' BlackJack''Rintsch
You want a dictionary.
M = dict()
for x in xrange(1, 4):
M[x] = Material(x)
Ciao,
Marc ''BlackJack'' Rintsch
这篇关于“变量名称”或“变量左值”或“变量值”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!