Extract Words from a file

后端 未结 3 619
野的像风
野的像风 2021-01-13 23:03

I open a file using python to find whether a predefined set of words are present in the opened file or not. I took the predefined set of words in a list and opened the file

3条回答
  •  一整个雨季
    2021-01-13 23:45

    You can do a few things

    • Call file.readlines() and split the entire text on your desired delimiter if your text isn't large
    • Call read() and do it bytes at a time

    Check out the pydocs for file - http://docs.python.org/release/2.5.2/lib/bltin-file-objects.html

提交回复
热议问题