在 Python 中,我试图让 for 循环迭代结果在引号中,以便它传递给循环中的另一个函数。这是我的代码以及我试图做的进一步解释:
read = pd.read_csv('Stocks.csv', header=None, delimiter=',')
for x in read[0]:
Ticker = x #I need the x iteration to have quotations around the result to pass into the results = si.get_quote_table(x, dict_result=False) import
results = si.get_quote_table(x, dict_result=False)
#The x in the parenthesis represents a stock ticker symbol from the csv file within the for loop. This will bring back data on the stock. It requires having quotations around the input for the si.get_quote_table to respond.
results.to_csv('Stockdata.csv', index=False)
我将不胜感激有人可以提供的任何帮助/指导。
先感谢您!
你可以这样做:
x = 'BTC'
y = f"'{x}'"
print(y)
输出:
'BTC'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句