Bläddra i källkod

Modified print to use str.format() instead of % replacement.

JonathanReem 12 år sedan
förälder
incheckning
139cd3cb4d
1 ändrade filer med 3 tillägg och 3 borttagningar
  1. 3 3
      3-tier.py

+ 3 - 3
3-tier.py

@@ -37,9 +37,9 @@ class Ui(object):
         product_info = self.business_logic.product_information(product)
         product_info = self.business_logic.product_information(product)
         if product_info is not None:
         if product_info is not None:
             print('PRODUCT INFORMATION:')
             print('PRODUCT INFORMATION:')
-            print('Name: %s, Price: %.2f, Quantity: %d\n' % \
-                  (product.title(), product_info.get('price', 0), \
-                   product_info.get('quantity', 0)))
+            print('Name: {:.s}, Price: {:.2f}, Quantity: {:.d}'.format(
+                   product.title(), product_info.get('price', 0),
+                   product_info.get('quantity', 0))
         else:
         else:
             print('That product "%s" does not exist in the records' % product)
             print('That product "%s" does not exist in the records' % product)