是否可以遍历结构?
例如
struct team{
int player1;
int player2;
int player3;
int player4;
...
int player99;
int size = 99;
}
Run Code Online (Sandbox Code Playgroud)
然后运行for循环来设置或访问foo 1-4?
我猜伪代码看起来像
for(int i = 0; i < size; i++){
player i = (i+1);
}
Run Code Online (Sandbox Code Playgroud)
一个更简单的解释,如果没有意义,我只是希望能够通过每个变量而不必硬编码player1 = 1; player2 = 2.
我正在尝试使用iexact
我的Django应用程序.
我在我的数据库类的物品test
,TEST
,tEsT
,和TesT
.
我试图找出test
我的数据库是否有任何形式.好像我需要使用iexact
但是我尝试使用它我收到了一个错误.
这是我的代码片段.
def item_search(x):
item = x.column_in_database
if test__iexact = 'test' in item:
return 1; #this is just pseduocode for stackoverflow
elif
return 0; #this is just pseduocode for stackoverflow
Run Code Online (Sandbox Code Playgroud)
我尝试过各种各样的方法,但我仍然无法让它发挥作用.