Python Forum
TypeError: coercing to Unicode: need string or buffer, int found
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: coercing to Unicode: need string or buffer, int found
#1
I get error on this line of my the script

saveTopCoin(newProfits[0][0] + " : " + newProfits[0][1])
error :
Traceback (most recent call last):
  File "WTM_AUTO_SWITCH2.py", line 100, in <module>
    saveTopCoin(newProfits[0][0] + " : " + newProfits[0][1])
TypeError: coercing to Unicode: need string or buffer, int found
Can any one help me ?
full script : https://pastebin.com/XZqaZgyq
Reply
#2
change
 
saveTopCoin(newProfits[0][0] + " : " + newProfits[0][1])
to
saveTopCoin('{0} : {1}'format(*newProfits[0]))
Reply
#3
Thanka lot for quick response

your solution gives error :

  File "WTM_AUTO_SWITCH2.py", line 80
    saveTopCoin('{0} : {1}'format(*newProfits[0]))
                                ^
SyntaxError: invalid syntax
But I solve it by this:

saveTopCoin(str(newProfits[0][0]) + ":" + str(newProfits[0][1]))
Reply
#4
sorry, just missed the dot
saveTopCoin('{0} : {1}'.format(*newProfits[0]))
yours is also OK, but I don't like concatenation - python has more nice tools :-)
Reply
#5
Cool, I'm very new to Python
Will try it again
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  boto3 - Error - TypeError: string indices must be integers kpatil 7 1,231 Jun-09-2023, 06:56 PM
Last Post: kpatil
  "TypeError: string indices must be integers, not 'str'" while not using any indices bul1t 2 2,011 Feb-11-2023, 07:03 PM
Last Post: deanhystad
  TypeError: string indices must be integers JonWayn 12 3,383 Aug-31-2022, 03:29 PM
Last Post: deanhystad
  Split string using variable found in a list japo85 2 1,295 Jul-11-2022, 08:52 AM
Last Post: japo85
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,850 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  Read buffer from bluetooth frohr 2 2,132 Jun-01-2022, 01:31 PM
Last Post: frohr
  TypeError: not enough arguments for format string MaartenRo 6 2,919 Jan-09-2022, 06:46 PM
Last Post: ibreeden
  TypeError: sequence item 0: expected str instance, float found Error Query eddywinch82 1 5,100 Sep-04-2021, 09:16 PM
Last Post: eddywinch82
  TypeError: int() argument must be a string, a bytes-like object or a number, not 'Non Anldra12 2 5,194 May-02-2021, 03:45 PM
Last Post: Anldra12
  TypeError: __str__ returned non-string (type tuple) Anldra12 1 7,394 Apr-13-2021, 07:50 AM
Last Post: Anldra12

Forum Jump:

User Panel Messages

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