设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索

求教 File.open 的正确用法

查看数: 1536 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2013-9-10 18:07

正文摘要:

本帖最后由 gaofei677 于 2013-9-10 18:19 编辑   我用File.open('Font_setting.txt', 'w') {|file| Marshal.dump('Font_setting = 2', file) }复制代码创建了一个名叫"Font_setting.txt" 但是我打开, ...

回复

satgo1546 发表于 2013-9-10 18:42:58
不用Marshal。
  1. somefile.write("Hello") # somefile.print("Hello") is also ok
复制代码

评分

参与人数 1星屑 +84 收起 理由
弗雷德 + 84 认可答案

查看全部评分

Sion 发表于 2013-9-10 18:37:45
写入文本用
  1. $t = File.open('xxx.txt', 'wb')
  2. $t.puts "hello world"
  3. $t.flush
复制代码
读取用
  1. $t = File.open('xxx.txt', 'rb')
复制代码
怎么获取字符串我就不知道了
一般存取数据直接用 Marshal 就行了,DataManager 里有参考的写法。

评分

参与人数 1星屑 +84 收起 理由
弗雷德 + 84 认可答案

查看全部评分

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-29 23:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表