Output file in Python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BurnTard
    New Member
    • May 2007
    • 52

    #16
    And instead of %s, couldn't I just have used str()?
    That wouldn't confuse me as much :D

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #17
      Originally posted by BurnTard
      And instead of %s, couldn't I just have used str()?
      That wouldn't confuse me as much :D
      Sure, but if you want to learn Python, you should learn how to use the string format operator '%'. Here's an example:[code=Python]>>> print 'The first number is', 12, 'and the second number is', 44.5689
      The first number is 12 and the second number is 44.5689
      >>> s = 'The first number is ' + str(12) + ' and the second number is ' + str(44.5689)
      >>> print s
      The first number is 12 and the second number is 44.5689
      >>> s = 'The first number is %s and the second number is %s' % (12,44.5689)
      >>> s
      'The first number is 12 and the second number is 44.5689'
      >>> [/code]

      Comment

      Working...