1.

load( io )

Load a document from the current io stream.

File.open( 'animals.yaml' ) { |yf| YAML::load( yf ) }
   #=> ['badger', 'elephant', 'tiger']


example:

require 'yaml'
yml = YAML::load(File.open('t.yml'))
p yml

Can also load from a string.

YAML.load( "--- :locked" )
   #=> :locked

2.
load_file( filepath )

Load a document from the file located at filepath.

YAML.load_file( 'animals.yaml' )
   #=> ['badger', 'elephant', 'tiger']

参考链接:http://www.ruby-doc.org/stdlib-1.8.7/libdoc/yaml/rdoc/YAML.html

相关文章:

  • 2022-01-04
  • 2021-10-09
  • 2021-12-09
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-01-04
猜你喜欢
  • 2021-10-27
  • 2022-01-01
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案