ruby 读取yaml文件
来源:互联网 发布:怎么养才能加入淘宝网 编辑:程序博客网 时间:2024/05/16 14:25
ruby 读取yaml文件
假如我们有一个写好的yaml文件:
program:
id: 1
input: 1 2
output: 3
注意:":" 后面必须有一个空格
读取方式:
require 'yaml'problem = YAML.load(File.open("a.yaml"))puts "problem id is #{problem["program"]["id"]}"puts "problem input is #{problem["program"]["input"]}"puts "problem output is #{problem["program"]["output"]}"
结果:
problem id is 1
problem input is 1 2
problem output is 3
require 'yaml'configuration = { 'color' => 'blue', 'font' => 'new romain', 'font-size' => 7 }open('text.cfg', 'w') { |f| YAML.dump(configuration, f) }open('text.cfg') { |f| puts f.read }open('text.cfg') { |f| YAML.load(f) }
- ruby 读取yaml文件
- yaml文件的设置及ruby读取yaml数据
- Java读取Yaml文件
- python读取yaml文件
- yaml资料的设置及ruby读取yaml数据
- 使用 Ruby 解析CSV文件&YAML文件
- 使用 Ruby 解析CSV文件&YAML文件
- 使用 python 读取 yaml 文件
- opencv2-XML和YAML文件的读取
- XML和YAML文件的读取
- OpenCV中读取YAML文件方法
- 使用eclipse创建,并读取yaml文件
- Ruby分片读取文件
- ruby读取、写入文件
- Ruby/Rails 中的YAML
- ruby中yaml yaml4r
- ruby 关于yaml
- OpenCV XML和YAML文件的写入和读取
- 五个砝码问题(用三进制)
- Struts2 单文件上传
- Python enumerate用法
- Android中软键盘的显示和隐藏
- Comments Off18 Tools and Source Code Components for Cocos2D iOS Game Development
- ruby 读取yaml文件
- 02-导入版权信息(jsp基本应用)
- Flash Player 问题 | Windows 8
- UVa 558 - Wormholes
- Python 深拷贝与浅拷贝
- 盘点木质和钢制办公家具保养
- Redis slowlog
- 今天 eclipse插件开发中的两个问题及解决
- 黑马程序员_基础加强(注解)