#定义一个价格序列
price_list=[5.78,5.80,5.81,5.82,5.87,5.85,5.87,5.80]
#for循环遍历价格列表
for ohlc_price in price_list:
for price in ohlc_price:
print('现在的价格为:',price)
运行结果如下:
D:\Anaconda3\python.exe D:/study_python/3.2.2.py
Traceback (most recent call last):
File "D:/study_python/3.2.2.py", line 40, in
for price in ohlc_price:
TypeError: 'float' object is not iterable
Process finished with exit code 1
如何解决,谢谢!