我想做的是点击关于此列表的某些代码的'shift-enter'并运行列表的每个元素 .
如果没有深入研究以这种方式解决这个问题,直接回答你的问题是这样的(规则将单元格分开以便更好地了解正在发生的事情):
import requests
mySuperCoolList=['response1=requests.get("https://api.iextrading.com/1.0/stock/EBND/quote")',
'response2=requests.get("https://api.iextrading.com/1.0/stock/EMB/quote")',
'response3=requests.get("https://api.iextrading.com/1.0/stock/XOMA/quote")',
'response4=requests.get("https://api.iextrading.com/1.0/stock/TUSK/quote")',
'response5=requests.get("https://api.iextrading.com/1.0/stock/CQH/quote")',
'response6=requests.get("https://api.iextrading.com/1.0/stock/DMLP/quote")']
for i in mySuperCoolList:
get_ipython().run_cell(i)
print(response1)
# ...
print(response6)
现在,虽然你说过,虽然你可以直接操作底层结构(run_cell,set_next_input等等)你的结果,但是如果没有别的话可以直接使用请求包,那么最好能够运行它常规python脚本后来没有太大的麻烦......
另外值得一提的是,除非由于某种原因你在你的真棒列表中确切地关注那些6个请求并且你绝对不想,想要扩展或收缩该列表,变量命名 response1..6 建议你可能想要把它们放在一些像样的结构中作为数组或列表 . 只是说......