import akshare as ak def fund(): # 获取建材ETF(159745)的最新行情 df = ak.fund_etf_hist_sina(symbol="sz159745") latest_price = df.iloc[-1]["close"] # 最新收盘价 print(f"建材ETF(159745)最新报价:{latest_price} 元") def price(): df = ak.stock_individual_spot_xq(symbol="sz159745") latest_price = df.query("item == '现价'")["value"].values[0] return latest_price if __name__ == '__main__': price()