你如何在 Python 中的 for 循环的结果周围加上引号?

编码器1044

在 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在python中删除字符串周围的引号?

如何在python中更好地组织你的代码?

你如何在 boost::python 中“从 __future__ 导入部门”?

你如何在python中解析嵌套的json数据

你如何在 Python 中操作嵌套列表?

你如何在网站中执行python代码

你将如何在 python 中创建变量(你会看到)

您是否应该在python中的类型注释周围加上引号

如何在SQL参数周围加上引号?

在JS中的字典键周围加上引号

如何在python中重置for循环的索引号

sqlplus中如何在字符串结果周围包含双引号?

如何在Python中的数据帧中获取for循环的结果

你知道如何在 python 中从同一个类中输入对象吗?

你如何在python中获得KMeans聚类中的X值?

你如何在 python 代码中更改 kivy 中的屏幕转换方向?

你如何在python中为变量分配返回值?

你如何在python中删除反斜杠和附加在反斜杠上的单词?

你如何在 Python 3 中管理函数作用域和同步

你如何在python中访问字典的第二个元素?

你如何在python的文本文件中搜索某个东西?

你如何在python中调用一个实例“内部”和“外部”的方法?

你能告诉我如何在Python Web Automation中添加多个代理吗

你如何在 Python 中从谷歌分析中分离源媒体路径?

你如何在 Python 中制作一个基本的全屏窗口?

你如何在 python 中按下特定的键来做某事?

你如何在python中取包含零的矩阵的平方根?

你如何在一行中打印最终结果?

Python,为什么csv writer会在值周围加上引号