爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2526|回复: 3

[混合编程] IDL编程学习之输出带表头的txt

[复制链接]

新浪微博达人勋

发表于 2018-8-8 14:02:50 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
/append代表续写,如果文件不存在就会自动生成一个
代码:
  openw,lun,'C:\Users\YGDY\Desktop\1.txt',/get_lun,/append
  printf,lun,' apple  pear  peach'
  close,/all
   
  openw,lun,'C:\Users\YGDY\Desktop\1.txt',/get_lun,/append
  printf,lun,findgen(3,4)
  close,/all



QQ截图20180808140142.jpg
以空格为间隔符在excel中打开:
QQ截图20180808140305.jpg

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-8-26 22:32:08 | 显示全部楼层
使用format很重要!!!可以对齐!!!IDL输出参考了fortran!!!

OPENW, lun, 'D:\a.txt', /get_lun, width=1000
    PRINTF, lun, ['apple', 'pear', 'peach'], format='(3A10)'
    PRINTF, lun, indgen(3, 3), format='(3I10)'
FREE_LUN, lun

######  output  ######
     apple      pear     peach
         0         1         2
         3         4         5
         6         7         8
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-8-26 22:32:14 | 显示全部楼层
使用format很重要!!!可以对齐!!!IDL输出参考了fortran!!!

OPENW, lun, 'D:\a.txt', /get_lun, width=1000
    PRINTF, lun, ['apple', 'pear', 'peach'], format='(3A10)'
    PRINTF, lun, indgen(3, 3), format='(3I10)'
FREE_LUN, lun

######  output  ######
     apple      pear     peach
         0         1         2
         3         4         5
         6         7         8
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-8-27 10:16:55 | 显示全部楼层
ybmy001 发表于 2018-8-26 22:32
使用format很重要!!!可以对齐!!!IDL输出参考了fortran!!!

OPENW, lun, 'D:\a.txt', /get_lun, ...

{:eb502:}
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

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