writedlm 格式化输出


#1

writedlm 怎么格式化输出,比如,数字的话,只输出固定的位数。我看文档里好像没有

help?> writedlm
search: writedlm

  writedlm(f, A, delim='\t'; opts)

  Write A (a vector, matrix, or an iterable collection of iterable rows) as text to f (either a
  filename string or an IO stream) using the given delimiter delim (which defaults to tab, but can
  be any printable Julia object, typically a Char or AbstractString).

  For example, two vectors x and y of the same length can be written as two columns of
  tab-delimited text to f by either writedlm(f, [x y]) or by writedlm(f, zip(x, y)).

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> using DelimitedFiles
  
  julia> x = [1; 2; 3; 4];
  
  julia> y = [5; 6; 7; 8];
  
  julia> open("delim_file.txt", "w") do io
             writedlm(io, [x y])
         end
  
  julia> readdlm("delim_file.txt", '\t', Int, '\n')
  4×2 Array{Int64,2}:
   1  5
   2  6
   3  7
   4  8
  
  julia> rm("delim_file.txt")