I am pretty new to python, The text i have is in text file like : {u'metro_name': u'Phoenix-Mesa-Glendale, AZ', u'ips': 38060} {u'metro_name': u'Los Angeles-Long Beach-Glendale, CA (MSAD)', u'ips': 31100}
如何仅打印Python中的值,并在一行中用$表示它们,即输出:
'Phoenix-Mesa-Glendale, AZ$$38060','Los Angeles-Long Beach-Glendale, CA (MSAD)$$31100'
我很确定regex不能完全解析字符串文本语法,所以这项工作比这里值得做的更多。考虑使用
ast.literal_eval
将每一行转换为字典。然后可以对它们的值执行任何字符串操作。你知道吗结果:
相关问题 更多 >
编程相关推荐