Python Forum
Need help amalgamating two scripts
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help amalgamating two scripts
#6
(Mar-07-2017, 04:46 PM)wavic Wrote: Consider that f.readlines() will create a list of all file lines. This can eat the memory. If the file is big enough.

Changed this as follows;

with open('debt.txt') as d:
    for line in d:
        print line.split()[1].replace("£", "")

I am working in eclipse and the output gives me what I want but replaces the "£" with "�" instead; 

-�500
+�280
+�962
-�2088

When I add the line print sum(line.split()[1].replace("£", "")) I get an error: TypeError: unsupported operand type(s) for +: 'int' and 'str'.
How can I remedy this?
Reply


Messages In This Thread
Need help amalgamating two scripts - by brocq_18 - Mar-07-2017, 02:24 PM
RE: Need help amalgamating two scripts - by Larz60+ - Mar-07-2017, 02:37 PM
RE: Need help amalgamating two scripts - by wavic - Mar-07-2017, 02:45 PM
RE: Need help amalgamating two scripts - by wavic - Mar-07-2017, 04:46 PM
RE: Need help amalgamating two scripts - by brocq_18 - Mar-20-2017, 11:36 AM
RE: Need help amalgamating two scripts - by Ofnuts - Mar-20-2017, 02:02 PM
RE: Need help amalgamating two scripts - by wavic - Mar-20-2017, 12:00 PM
RE: Need help amalgamating two scripts - by Ofnuts - Mar-21-2017, 12:51 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020