search

Home  >  Q&A  >  body text

python for in嵌套有限制?


上图是代码,‘发现一个匹配’,并break之后,for line3 in g3.readlines():就再也不执行了。搜索相关问题,有回答说迭代有次数限制的,请教Python大神解答。X_X 下图是运行结果

PHP中文网PHP中文网2887 days ago425

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 17:42:35

    This way of writing is so strange. Does the file pointer need to be reset?
    To open two files, you can do this

    with open("1.txt") as IN1, open("2.txt") as IN2:

    reply
    0
  • 阿神

    阿神2017-04-17 17:42:35

    Problem solved The second for in failed to read g3 in a loop
    https://www.zhihu.com/question/45370193?from=profile_question_card

    reply
    0
  • Cancelreply