问题
If I run Mathematica as "math foo bar", what variable(s) hold foo and bar? I'm guessing it's $Something, but haven't found it.
Googling told me Mathematica accepts command-line options like -pwpath, -pwfile, but I couldn't find the right search phrase for actual command line arguments (not options).
回答1:
The $CommandLine
variable holds the command line arguments.
$ math foo bar
In[1]:= $CommandLine
Out[1]= {math, foo, bar}
来源:https://stackoverflow.com/questions/7149252/if-doing-math-foo-bar-how-to-get-foo-and-bar-inside-mathematica