Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python for带有数组的循环_Python_Loops_For Loop - Fatal编程技术网

Python for带有数组的循环

Python for带有数组的循环,python,loops,for-loop,Python,Loops,For Loop,我想创建这个for循环,但是循环中的文本被引用了。 请问怎么做? 非常感谢。 图像中的是引号,是f字符串,但他们忘记添加f year = [2016,2017,2018,2019,2020] for i in year: rtx_price = (data.loc[f'{year}-07-31', 'RTX']) 您能否在此平台上共享代码,而不是链接。此外,尽量不要在图像中添加代码当您将代码直接发布到此问题中时,请包含有关数据对象的信息。熊猫数据帧?如果它是熊猫,基本的位置索引是隐藏在

我想创建这个for循环,但是循环中的文本被引用了。 请问怎么做? 非常感谢。
图像中的是引号,是f字符串,但他们忘记添加f

year = [2016,2017,2018,2019,2020]

for i in year:
   rtx_price = (data.loc[f'{year}-07-31', 'RTX'])

您能否在此平台上共享代码,而不是链接。此外,尽量不要在图像中添加代码当您将代码直接发布到此问题中时,请包含有关
数据
对象的信息。熊猫数据帧?如果它是熊猫,基本的位置索引是隐藏在你的问题不清楚的文件。你想要达到的目标。请详细说明这个问题。嗨。我仍然需要每次选择不同的日期,例如2016年、2017年、2018年等等。在这种情况下,在f字符串“不使用年份”中,使用ihi。我还有另一个类似的问题。当前_比率=[]表示范围内的i(len(year)):当前_比率.append(get_value(f'current_assets_uu{year[i]-1}'))打印(当前_比率)当我打印数组时,会出现当前_assets_2016等字符串,而我希望将数值附加到这些字符串上,如第二个ss中所示