import pandas as pd
def get_stat(symbol, stat):
df = pd.read_csv(f"{symbol}.csv")
return df['close'].f"{stat}"()
def test_run():
for symbol in ['nugt', 'soxs']:
for stat in ['max','min', 'mean']:
print(f"{stat} Close")
print(symbol, get_stat(symbol))
if __name__ == "__main__":
test_run()
“stat”变量不会在“test_run”函数和“get_stat”函数之间进行链接,而“get_stat”函数又不允许我在.f"stat"()
部分调用它。我的目标是看到这样的结果: