0

我正在将 yfinance 中的代码拉到一个列表中并尝试打印该列表。打印时,列表打印时将字符添加到每个股票代码。我想删除这些字符并尝试使用lstripandrstrip函数,但我继续获得添加的字符。下面是输入代码:

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 对象<”和“>”。

4

1 回答 1

0

您可以使用以下ticker属性:

edited_buylist = [i.ticker for i in edited_buylist]
print("The list of securities that are at or near support points are: ", str(edited_buylist))
于 2019-12-28T04:18:19.590 回答