我正在将 yfinance 中的代码拉到一个列表中并尝试打印该列表。打印时,列表打印时将字符添加到每个股票代码。我想删除这些字符并尝试使用lstrip
andrstrip
函数,但我继续获得添加的字符。下面是输入代码:
for i in edited_buylist:
i = str(i)
i = i.lstrip('yfinance.Ticker object <')
for i in edited_buylist:
i = str(i)
i = i.rstrip('>')
print("The list of securities that are at or near support points are: ", str(edited_buylist))
以下是该代码的输出:
The list of securities that are at or near support points are: [yfinance.Ticker object <VVV>]
'''
我想删除“yfinance.Ticker 对象<”和“>”。