user13104924
user13104924

Reputation:

python:How can I print out my file lines?

I have this function.

def write_file(tmpdir, filename):
    full_file_name = tmpdir/filename 
with openFile(filename) as p:
    lines = p.readlines()
return lines

I have pass my filename. For example file.txt ,and there can be written everything. How can I print out all of the lines of the file.txt file in this write_file function?

Upvotes: 0

Views: 45

Answers (1)

Cblopez
Cblopez

Reputation: 566

Generic syntax to print the file lines

with open(your_file, 'r') as f:
    print(''.join([for x in f.readlines()]))

Upvotes: 0

Related Questions