python - Importing a text file in Python2.7 -


this question has answer here:

i want import external files in python. how can it?

will work import module or there other way it?

e.g file name hex.txt.

you can grab file , loop lines stuff this:

filehandle = open("hex.txt", "r") line in filehandle:     print (line) 

or grab whole file string:

with open("hex.txt", "r") myfile:     data=myfile.read() 

there several different ways depending on planning on doing data. search around on stackoverflow should started.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -