标签: action

metavar和action在Python中的argparse中意味着什么?

我正在阅读argparse模块.因为metavar和行动意味着什么,我陷入了困境

>>> parser.add_argument('integers', metavar='N', type=int, nargs='+',
...                     help='an integer for the accumulator')
>>> parser.add_argument('--sum', dest='accumulate', action='store_const',
...                     const=sum, default=max,
...                     help='sum the integers (default: find the max)')
Run Code Online (Sandbox Code Playgroud)

我可能错过了,但从我读到的,我找不到metavar和的 定义action (action="store_const", etc).他们究竟是什么意思?

python action argparse

50
推荐指数
2
解决办法
4万
查看次数

在按钮操作上传递参数:@selector

我想将动态生成按钮中的电影网址传递给MediaPlayer:

[button addTarget:self action:@selector(buttonPressed:) withObject:[speakers_mp4 objectAtIndex:[indexPath row]] forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)

action:@selector() withObject:不起作用?

还有其他解决方案吗?

感谢帮助!

iphone parameters action selector media-player

49
推荐指数
4
解决办法
11万
查看次数

不同控制器上的.NET MVC调用方法

任何人都可以告诉我如何在动作方法中调用不同控制器上的方法吗?我不想重定向.我想在不同的控制器上调用一个方法,该控制器返回一个字符串并在我的action方法中使用响应.

.net asp.net-mvc action

47
推荐指数
5
解决办法
8万
查看次数

在Asp.Net Mvc 4中使用Cookie

我在Asp.Net MVC4中有Web应用程序,我想使用cookie进行用户登录和注销.所以我的行动如下:

登录操作

    [HttpPost]
    public ActionResult Login(string username, string pass)
    {
        if (ModelState.IsValid)
        {
            var newUser = _userRepository.GetUserByNameAndPassword(username, pass);
            if (newUser != null)
            {
                var json = JsonConvert.SerializeObject(newUser);

                var userCookie = new HttpCookie("user", json);
                userCookie.Expires.AddDays(365);
                HttpContext.Response.Cookies.Add(userCookie);

                return RedirectToActionPermanent("Index");
            }
        }
        return View("UserLog");
    }
Run Code Online (Sandbox Code Playgroud)

LogOut Action

    public ActionResult UserOut()
    {
        if (Request.Cookies["user"] != null)
        {
            var user = new HttpCookie("user")
                {
                    Expires = DateTime.Now.AddDays(-1),
                    Value = null
                };
            Response.Cookies.Add(user);
        }
        return RedirectToActionPermanent("UserLog");
    }
Run Code Online (Sandbox Code Playgroud)

我在_Loyout中使用此cookie如下:

@using EShop.Core
@using …
Run Code Online (Sandbox Code Playgroud)

c# cookies action httpcookie asp.net-mvc-4

47
推荐指数
2
解决办法
11万
查看次数

Ansible - 打印消息 - 调试:msg ="line1 \n {{var2}} \n line3 with var3 = {{var3}}"

在Ansible(1.9.4)或2.0.0中

我运行了以下操作:

- debug: msg="line1 \n {{ var2 }} \n line3 with var3 = {{ var3 }}"
Run Code Online (Sandbox Code Playgroud)

$ cat roles/setup_jenkins_slave/tasks/main.yml

- debug: msg="Installing swarm slave = {{ slave_name }} at {{ slaves_dir }}/{{ slave_name }}"
  tags:
    - koba

- debug: msg="1 == Slave properties = fsroot[ {{ slave_fsroot }} ], master[ {{ slave_master }} ], connectingToMasterAs[ {{ slave_user }} ], description[ {{ slave_desc }} ], No.Of.Executors[ {{ slave_execs }} ], LABELs[ {{ slave_labels }} ], mode[ {{ slave_mode }} ]" …
Run Code Online (Sandbox Code Playgroud)

action newline roles ansible ansible-playbook

47
推荐指数
7
解决办法
5万
查看次数

如何在Qt Creator中连接菜单点击操作?

我对Qt完全不熟悉.

我开始使用新的Qt4 GUI应用程序.

使用设计器,我创建了一个菜单,如下所示:

File
 - Exit
Run Code Online (Sandbox Code Playgroud)

如何获取与菜单项关联的操作?

我发现了一些名为"信号和插槽编辑器"但却不知道如何使用它的东西.

qt action menu

45
推荐指数
4
解决办法
6万
查看次数

HTML表单操作和onsubmit问题

我想在一些文本框条目上运行javascript用户验证.

我遇到的问题是我的表单有进入我们网站内新页面的操作,该onsubmit属性从不运行javascript函数.

是否有更好的解决方案,或使用以下代码的解决方案:注意:javascript文件写得正确,并且如果您将操作切换到,则有效checkRegistration().

这只是运行动作和javascript的问题.

<form name="registerForm" action="validate.html" onsubmit="checkRegistration()" method="post">
    <!-- textboxes here -->
    <!-- and submit button -->
</form>
Run Code Online (Sandbox Code Playgroud)

javascript forms html5 action onsubmit

41
推荐指数
3
解决办法
18万
查看次数

我可以在Action或Func委托中使用params吗?

当我试图在Action委托中使用params时......

private Action<string, params object[]> WriteToLogCallBack;
Run Code Online (Sandbox Code Playgroud)

我收到了这个设计时错误:

类,结构或接口成员声明中的标记'params'无效

任何帮助!

c# delegates action params-keyword

39
推荐指数
3
解决办法
2万
查看次数

Android Notification按钮未显示

这是我用按钮设置通知的代码.

Intent receiverIntent = new Intent(ctx, ResponsivePrefsActivity.class);
        PendingIntent pReceiverIntent = PendingIntent.getActivity(ctx, 1, receiverIntent, 0);
        Intent clearIntent = new Intent(ctx, ResponsivePrefsActivity.class);
        clearIntent.setAction("clear");
        PendingIntent pClearIntent = PendingIntent.getActivity(ctx, 1, clearIntent, 0);

        Intent colorsIntent = new Intent(ctx, ResponsivePrefsActivity.class);
        colorsIntent.setAction("colors");
        PendingIntent pColorsIntent = PendingIntent.getActivity(ctx, 1, colorsIntent, 0);

        Intent animationIntent = new Intent(ctx, ResponsivePrefsActivity.class);
        animationIntent.setAction("animation");
        PendingIntent pAnimation = PendingIntent.getActivity(ctx, 1, animationIntent, 0);

        Notification.Builder builder;
        builder = new Notification.Builder(ctx).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(false)
                .setContentTitle("Draw Me: A Live Wallpaper").setContentText("Never get bored again!")
                .setContentIntent(pReceiverIntent).addAction(R.raw.ic_menu_close_clear_cancel, "Clear", pClearIntent)
                .addAction(R.raw.ic_menu_edit, "Colors", pColorsIntent).addAction(R.raw.ic_menu_play_clip, "Animation", pAnimation);
        Notification notification …
Run Code Online (Sandbox Code Playgroud)

notifications android action button

38
推荐指数
4
解决办法
2万
查看次数

如何在每个操作的基础上禁用Ruby on Rails中的日志记录?

我有一个Rails应用程序,它有一个经常被调用的动作,在我开发时很不方便,因为它导致了很多额外的日志输出我不关心.如何才能让rails不记录任何内容(控制器,动作,参数,计算时间等)?我也想在RAILS_ENV上对其进行条件化,因此生产中的日志已经完成.

谢谢!

logging conditional action ruby-on-rails

37
推荐指数
5
解决办法
2万
查看次数