Click here to Skip to main content
15,888,218 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi im not a programmer can you help me t add a perp in the end of each output like
binance : btcusdt,binance : ltcusdt, ...etc to be ===>
binance:btcusdtperp,
binance :ltcusdtperp,....etc
thank you .


What I have tried:

import requests

data = requests.get('https://api.binance.com/api/v1/exchangeInfo').json()
symbols = map(lambda x: 'BINANCE:{}'.format(x['symbol']), data['symbols'])
symbols = filter(lambda x: 'USDT' in x, symbols)

print(','.join(symbols))
Posted
Updated 27-Sep-20 11:43am

1 solution

With your code, simplest modification would be to use delimiter: '\n' in your join.
Try:
Python
import requests

data = requests.get('https://api.binance.com/api/v1/exchangeInfo').json()
symbols = map(lambda x: 'BINANCE:{}'.format(x['symbol']), data['symbols'])
symbols = filter(lambda x: 'USDT' in x, symbols)

print(',\n'.join(symbols))
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900