我有一个如下所示的字典,我需要删除密钥中的$符号,并且需要存储在一个单独的数组中,其中显示的数据与此处显示的相同,是否有人可以帮助我如何从所有密钥中删除美元?
var products = ["$50-$60": 50-60, "$30-$40": 30-40, "$0-$10": -10, "$20-$30": 20-30, "$90-and above": 90-, "$40-$50": 40-50, "$80-$90": 80-90, "$70-$80": 70-80, "$10-$20": 10-20, "$60-$70": 60-70]
答案 0 :(得分:0)
我希望你想要一个数组中的键集,据我所知
var dollarRemovedArray = products.map{$0.key.replacingOccurrences(of: "$", with: "")}
输出将是这样的 -
[" 50-60"," 30-40"," 0-10"," 20-30",&# 34; 90-及以上"," 40-50"," 80-90", " 70-80"," 10-20"," 60-70"]