Force YAML values to be strings
问题 Look at this code, under Python 2.7: >>> import yaml >>> yaml.load('string: 01') {'string': 1} >>> :( Is it possible to obtain the string 01 without modifying the yaml file? I didn't find anything in the docs. 回答1: Try: >> import yaml >> yaml.load('string: 01', Loader=yaml.loader.BaseLoader) {u'string': u'01'} 回答2: I was seeking for exactly the opposite effect: Numbers where being converted to stings, but numbers where wanted. I was using accidentally the BaseLoader (Dame copy-paste!). The