将参数从cmd传递给python脚本(Pass arguments from cmd to python script)
我在python中编写脚本并通过输入以下命令运行cmd:
C:\> python script.py
我的一些脚本包含基于标志调用的单独算法和方法。 现在我想通过cmd直接传递标志,而不是必须进入脚本并在运行之前更改标志,我想要类似于:
C:\> python script.py -algorithm=2
我已经读过人们使用sys.argv几乎是类似的目的,但阅读手册和论坛我无法理解它是如何工作的。
I write my scripts in python and run them with cmd by typing in:
C:\> python script.py
Some of my scripts contain separate algorithms and methods which are called based on a flag. Now I would like to pass the flag through cmd directly rather than having to go into the script and change the flag prior to run, I want something similar to:
C:\> python script.py -algorithm=2
I have read that people use sys.argv for almost similar purposes however reading the manuals and forums I couldn't understand how it works.
原文:https://stackoverflow.com/questions/16712795
最满意答案
不幸的是,现在我们无法通过VS将Web应用程序部署到Azure linux服务计划。 我们只能在VS发布过程中看到Windows服务计划。
然而,我们有其他选择。
FTP--将预编译的文件(在〜/ bin / Debug(Release)文件夹下)上传到网站。 这是参考 。
本地Git - 您可能已阅读本教程 。 请注意,Git bash也可以在Windows中使用。
GitHub - 按照此参考将VS与您的GitHub连接,然后在门户中配置部署选项。 之后,您的代码将被推送到GitHub后自动部署。
还有一些其他的部署方式,如门户中的CI / CD(也称为持续交付)和另一个源控制工具BitBucket。 我建议你使用GitHub,因为它很容易在配置后在VS中运行。
Unfortunately, for now we cannot deploy web app to Azure linux service plan through VS. It's by design that we can only see windows service plan in VS publish process.
However there are alternatives for us to choose.
FTP-- Upload pre-compiled files(under ~/bin/Debug(Release) folder) to website. Here's the reference.
Local Git--You may have read this tutorial. Note that Git bash can also be used in Windows.
GitHub--Follow this reference to connect VS with your GitHub, then config Deployment option in portal. After that your code will be deployed automatically once pushed to GitHub.
There are some other deployment ways like CI/CD aka Continuous Delivery in portal and another source control tool BitBucket. I recommend you to use GitHub as it's simple to operate in VS after configuration.
相关问答
更多-
不幸的是,现在我们无法通过VS将Web应用程序部署到Azure linux服务计划。 我们只能在VS发布过程中看到Windows服务计划。 然而,我们有其他选择。 FTP--将预编译的文件(在〜/ bin / Debug(Release)文件夹下)上传到网站。 这是参考 。 本地Git - 您可能已阅读本教程 。 请注意,Git bash也可以在Windows中使用。 GitHub - 按照此参考将VS与您的GitHub连接,然后在门户中配置部署选项。 之后,您的代码将被推送到GitHub后自动部署。 还有 ...
-
所以我的问题是由两件事引起的: 有ARR亲和力,这使得连续请求转到同一个实例, 这里是教程如何禁用它。 我不知道Google的6 ,所以我的请求在本地停滞不前 So my problem was caused by two things: there is ARR affinity , which makes consecutive requests go to the same instance, here is tutorial how to disable it. I didn't know abou ...
-
我认为Visual Studio中有些东西丢失,当我尝试发布它时,我有以下所有选项: 我有Azure SDK 2.9,alsio检查你有Microsoft ASPNET和Web工具的最新版本(现在,我有版本14) I think something is lose in your Visual Studio, when I try to publish it, I have all the options: I have the Azure SDK 2.9, alsio check you have the ...
-
我的问题是我的appsettings.json文件中出现语法错误。 我只是错过了一个逗号。 我的建议是检查任何* .json设置文件是否存在语法错误。 IMO,查看所述文件中任何警告的最简单方法是使用错误列表窗口。 My problem was a syntax error in my appsettings.json file. I was simply missing a comma. My suggestion is to check any of the *.json settings files ...
-
运行dnx publish或dotnet publish ,您将获得已发布的应用程序。 然后复制docker容器中的所有文件或将复制步骤添加到dockerfile Run dnx publish or dotnet publish and you'll get the published app. Then copy all the files in docker container or add the copy step to the dockerfile
-
您的问题与以下内容重复: 如何将ASP.NET 5 Preview Web项目转换为Cloud Service 该主题的答案: 它还没有得到支持。 但是,如果您愿意,您可以创建一个安装脚本来安装所有需要的组件,然后您可以按照这篇文章中的步骤运行它并引导您的应用程序: http : //www.codeproject.com/Articles/331425/磨合的-EXE-IN-A-WebRole-ON-Windows的天青 Your question is a duplicate of: How to co ...
-
编辑 :请注意,这仅适用于RC1。 RC2不支持那些可执行文件。 他们将被dotnet-cli取代。 我想我知道你想要什么,但如果不是那个,请告诉我,我会调整我的答案。 dnvm:.NET版本管理器 管理不同的运行时,还允许您选择当前运行时。 dnu:.NET实用程序 管理包裹。 一旦您启动并运行应用程序,主要用于dnu restore 。 dnx:.NET执行引擎 通过执行命令运行您的应用程序/网站。 通常dnx web但web是在你的project.json定义的,所以它可以是任何东西。 那么如何更改运 ...
-
似乎微软只关心.NET Core,并假设所有应用程序都可以轻松转换。 这远非如此。 所有Azure Web Apps都具有完整的.NET框架。 通过FTP将Web应用程序部署到Azure很简单。 看看使用FTP / S将您的应用程序部署到Azure App Service 简而言之: 设置部署凭据 获取FTP连接信息 将文件部署到Azure 我有一个问题:如果你只有Visual Studio for Mac可用,你如何构建运行完整框架的ASP.NET MVC应用程序? 编辑 此资源可能也很有趣: 在Azur ...
-
将ASP.Net Core应用程序发布到Azure会在命令行中静默失败(Publishing ASP.Net Core app to Azure silently fails in command line)[2022-02-03]
在通过publish-module.psm1进行调试以找出为什么没有部署的情况下,我注意到需要该命令来提供更多参数。 这是如何: .\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml' -publishProperties @{ 'username' = '%PublishProfile.Username%' 'Password' = ' ... -
Visual Studio中的asp.net核心项目之间的区别(Difference between asp.net core projects in Visual Studio)[2021-10-17]
这都是关于运行时的 第一个选项是在.net 4.x运行时上运行的ASP.NET(Full,legacy,无论您想要调用它)。 第二个选项是在.NET Core Runtime上运行的ASP.NET Core(一组适用于所有平台的通用功能)。 第三个选项是在.NET 4.x运行时上运行的ASP.NET Core。 这个选项在那里你可以编写今天的.NET Core应用程序,即使你可能需要只在.net 4.x上可用的功能(即,你有遗留的库未被移植到.net核心,或者那个无法运行.net核心) 在第三种情况下,您可 ...