Your first example wouldn't work in any language as you are trying to redefine the variable "i". It's an int in the loop control, but a string in the body of the loop.
Use some sort of eval if it is available in the language.
如果可以使用该语言,请使用某种eval。
#6
This depends on the language.
这取决于语言。
Commonly when people want to do this, the correct thing is to use a data structure such as a hash table / dictionary / map that stores key names and associated values.