소스 검색

Added a second example on print formatting.

Gogs 7 년 전
부모
커밋
cc43b6c397
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      examples/simplefunction.py

+ 1 - 1
examples/simplefunction.py

@@ -2,7 +2,7 @@ def example(firstargument, secondargument, thirdargument="N/A"):
     """ Prints a string based on the two arguments. """
     # This is python3.6 syntax:
 #    print(f"{firstargument} is the first argument.")
-    print("{} is the first argument.".format(firstargument))
+    print("{a} is the first argument.".format(a = firstargument)) # Name the argument if you want
     print("{} is the second argument.".format(secondargument))
     print("{} is the third argument.".format(thirdargument))