logo

How to Insert Command Line Arguments in Julia 📂Julia

How to Insert Command Line Arguments in Julia

English Translation

Code

println(ARGS[1] * " + " * ARGS[2] * " = " * string(parse(Float64, ARGS[1]) + parse(Float64, ARGS[2])))

Let’s say we have a file named example.jl that consists of a single line as shown above. In Julia, we can receive command line arguments as an array through ARGS, similar to how sys.argv works with command line arguments in Python. The code written is a program that takes two numbers and prints their sum. The execution result is as follows.

20211114_224320.png

Environment

  • OS: Windows
  • julia: v1.6.3