如何从字符串中的共同元素中创建字典
我需要从具有相同第一个字符的字符串中的所有秒字符。
这是我的代码:
Coin_Info = Binance_Client.get_all_coins_info()
for n in Coin_Info:
Coin, Net = n['coin'], n['networkList']
for e in Net:
if e['depositEnable'] and e['withdrawEnable'] is True:
print(Coin, e['network'])
输出:
GALA BSC
GALA ETH
VIB ETH
FIS BSC
FIS ETH
BAR CHZ
RAD ETH
COTI BSC
COTI BNB
COTI ETH
但是我需要在这样的词典中转换它:
GALA = {'BSC', 'ETH'}
VIB = {'ETH'}
FIS = {'BSC', 'ETH'}
BAR = {'CHZ'}
RAD = {'ETH'}
COTI = {'BSC', 'BNB', 'ETH'}
预先感谢您!
I need to put all the seconds character from a string that have the same first character in common.
This is my code:
Coin_Info = Binance_Client.get_all_coins_info()
for n in Coin_Info:
Coin, Net = n['coin'], n['networkList']
for e in Net:
if e['depositEnable'] and e['withdrawEnable'] is True:
print(Coin, e['network'])
output:
GALA BSC
GALA ETH
VIB ETH
FIS BSC
FIS ETH
BAR CHZ
RAD ETH
COTI BSC
COTI BNB
COTI ETH
but i need to transform it in a dictionary like this:
GALA = {'BSC', 'ETH'}
VIB = {'ETH'}
FIS = {'BSC', 'ETH'}
BAR = {'CHZ'}
RAD = {'ETH'}
COTI = {'BSC', 'BNB', 'ETH'}
thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下操作:
Try this: