打印两个参数

时间:2016-02-08 21:49:58

标签: haskell

我正在尝试import win32com.client shell = win32com.client.Dispatch("WScript.Shell") shell.Run("notepad") shell.AppActivate("Notepad") def a(): shell.SendKeys("{a}", 0) def A(): shell.SendKeys("{A}", 0) def b(): shell.SendKeys("{b}", 0) def B(): shell.SendKeys("{B}", 0) def c(): shell.SendKeys("{c}", 0) def C(): shell.SendKeys("{C}", 0) def d(): shell.SendKeys("{d}", 0) def D(): shell.SendKeys("{D}", 0) def e(): shell.SendKeys("{e}", 0) def E(): shell.SendKeys("{E}", 0) def f(): shell.SendKeys("{f}", 0) def F(): shell.SendKeys("{F}", 0) def g(): shell.SendKeys("{g}", 0) def G(): shell.SendKeys("{G}", 0) def h(): shell.SendKeys("{h}", 0) def H(): shell.SendKeys("{H}", 0) def i(): shell.SendKeys("{i}", 0) def I(): shell.SendKeys("{I}", 0) def j(): shell.SendKeys("{j}", 0) def J(): shell.SendKeys("{J}", 0) def k(): shell.SendKeys("{k}", 0) def K(): shell.SendKeys("{K}", 0) def l(): shell.SendKeys("{l}", 0) def L(): shell.SendKeys("{L}", 0) def m(): shell.SendKeys("{m}", 0) def M(): shell.SendKeys("{M}", 0) def n(): shell.SendKeys("{n}", 0) def N(): shell.SendKeys("{N}", 0) def o(): shell.SendKeys("{o}", 0) def O(): shell.SendKeys("{O}", 0) def p(): shell.SendKeys("{p}", 0) def P(): shell.SendKeys("{P}", 0) def q(): shell.SendKeys("{q}", 0) def Q(): shell.SendKeys("{Q}", 0) def r(): shell.SendKeys("{r}", 0) def R(): shell.SendKeys("{R}", 0) def s(): shell.SendKeys("{s}", 0) def S(): shell.SendKeys("{S}", 0) def t(): shell.SendKeys("{t}", 0) def T(): shell.SendKeys("{T}", 0) def u(): shell.SendKeys("{u}", 0) def U(): shell.SendKeys("{U}", 0) def w(): shell.SendKeys("{w}", 0) def W(): shell.SendKeys("{W}", 0) def x(): shell.SendKeys("{x}", 0) def X(): shell.SendKeys("{X}", 0) def y(): shell.SendKeys("{y}", 0) def Y(): shell.SendKeys("{Y}", 0) def z(): shell.SendKeys("{z}", 0) def Z(): shell.SendKeys("{Z}", 0) def enter(): shell.SendKeys("{ENTER}", 0) a(), A(), b(), B(), c(), C(), d(), D(), e(), E(), f(), F(), g(), G(), h(), H(), i(), I(), j(), J(), k(), K(), l(), L(), m(), M(), n(), N(), o(), O(), p(), P(), q(), Q(), r(), R(), s(), S(), t(), T(), u(), U(), w(), W(), x(), X(), y(), Y(), z(), Z(), enter(), 文件" hello.hs"并继续得到以下错误。

我正在使用WinGHCi 1.0.6。

我只打印了一个参数并且它有效但当我尝试打印两个参数时,我收到:load错误,如下所示。

我的hello.hs代码包含以下代码。

----------------- hello.hs --------------------

Not in scope

----------尝试时出错:加载命令--------

module Main where
import System.Environment
main :: IO ( )
main = do 
        args <- getArgs  --Getting first arg
        putStrLn("Hello," ++args!!0)
    do  args1 <- getArgs putStrLn("Hello," ++args1!!1)  --Getting second arg

1 个答案:

答案 0 :(得分:3)

system.out命令放在单独的行上。第二个Math Operation at 0 is Math Operation at 1 is + Math Operation at 2 is * 不是必需的(事实上,有必要没有它)。另外,您应该知道编译器将硬选项卡视为填充到下一个八维空间边界;所以尽管事情在SO上看起来正确缩进,但是你的代码的标签和空格的混合是不正确的。我建议使用putStrLn块中每行开头的单个标签或将所有标签转换为空格。另见my diatribe on tab styles。所以:

do

这是使事情有效的最小变化。另外,由于我认为没有理由相信两个调用do之间的参数会发生变化,因此您可以省略第二个调用并简单地重用main = do args <- getArgs --Getting first arg putStrLn("Hello," ++args!!0) args1 <- getArgs putStrLn("Hello," ++args1!!1) --Getting second arg

getArgs