![](/img/trans.png)
[英]Given a list of [string, number] tuples, create a dictionary where keys are the first characters of strings and the values are sums of the numbers
[英]Create dictionary where values are keys transformed to strings
G<\/code>是一个图形对象,
sorted(G)<\/code>返回一个节点列表:
[0,1,2...1860]
使用字典推导式创建字典,并使用字符串格式将数字转换为相应的字符串。
mapping = {x: f'{x}_cereb' for x in G}
答案是听写理解
mapping = {k: f"{k}_cereb" for k in sorted(G)}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.