1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-26 08:07:33 +02:00

Merge pull request #1227 from foochuanwei/patch-1

[Python3/en] Corrected Python3 print() function
This commit is contained in:
ven
2015-09-05 16:02:09 +02:00

View File

@@ -375,12 +375,12 @@ except (TypeError, NameError):
else: # Optional clause to the try/except block. Must follow all except blocks else: # Optional clause to the try/except block. Must follow all except blocks
print("All good!") # Runs only if the code in try raises no exceptions print("All good!") # Runs only if the code in try raises no exceptions
finally: # Execute under all circumstances finally: # Execute under all circumstances
print "We can clean up resources here" print("We can clean up resources here")
# Instead of try/finally to cleanup resources you can use a with statement # Instead of try/finally to cleanup resources you can use a with statement
with open("myfile.txt") as f: with open("myfile.txt") as f:
for line in f: for line in f:
print line print(line)
# Python offers a fundamental abstraction called the Iterable. # Python offers a fundamental abstraction called the Iterable.
# An iterable is an object that can be treated as a sequence. # An iterable is an object that can be treated as a sequence.