python - 如何在python中的double for循环中进行迭代
问题描述
我只想在第一次迭代中从 token1_list 和 token2_list 中获取第一个元素,在第二次迭代中获取第二个元素。目前在第一次迭代中,它正在从我的列表中获取所有元素,有没有办法解决这个问题?
char_list = []
for i in line_list:
case1test = case1[int(i)-1]
case1test1 = case1test.split()
[char_list.append(case1test1[int(a):int(b)+1]) for a in token1_list for b in token2_list]
解决方案
推荐阅读
- javascript - 如何使用 async/await 一一进行异步调用?
- python - 如何优化 for 循环以使用 2-D 数组中的值填充 3-D np 数组?
- rust - 展平大数组常量会减少 L1 缓存未命中的数量吗?
- tailwind-css - 你能把 Tailwind 和 vanilla CSS 混合起来吗?
- regex - LEX中匹配不以换行符开头的字符串的正则表达式是什么
- codeigniter-3 - 使用 codeignitor 将图像上传到重定向的文件夹
- powershell - Powershell合并来自不同文件的2列,没有关键字段
- r - 绘制具有已知误差的时间序列 (ggplot2)
- java - 响应从 servlet 重定向到 jsp 后,jsp 页面中的关闭按钮不起作用
- python - 从 pandas 日期时间列中提取唯一的月度周期