Last active
December 27, 2015 10:09
-
-
Save paulofreitas/7309152 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Alteração in-place | |
with open('dados1.txt', 'r+w') as f: | |
lines = [' '.join(l.split() + [str(reduce(lambda x, y: x * y, map(int, l.split())))]) for l in f] | |
f.seek(0) | |
f.write('\n'.join(lines)) | |
# Dois arquivos | |
open('dados2.txt', 'w').write('\n'.join(' '.join(l.split() + [str(reduce( | |
lambda x, y: x * y, map(int, l.split())))]) for l in open('dados1.txt'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment