If f is a string variable, t.getAttr(f) return wrong value, why?

I am using t.getAttr() to get data from the target attribute,but I want to get a set of attribute, so I want to use t.getAttr(f) which f is a variable enumerated in a set.

my question is if I use a string variale in vertex.getAttr(), it will return a wrong value(0, exactly).