批处理脚本读取用户输入问题(problem in batch script read user input)
我使用下面的
set /p
来读取用户输入,它似乎在if块之外工作,但是如果块不工作,则在里面。 当我第二次运行脚本时,if块中的用户输入会打印上一个用户输入。测试脚本:
@echo off set cond=true echo %cond% if %cond%==true ( echo "cond is true" REM the below input doesn't work set /p name1="enter your name" echo name is: %name1% ) REM it works here set /p name2="enter your name" echo name is: %name2%
谢谢
i use
set /p
below to read user input it seems to work outside the if block but the one inside if block doesn't work. When i run the script second time the user input in the if block prints the previous user input.test script:
@echo off set cond=true echo %cond% if %cond%==true ( echo "cond is true" REM the below input doesn't work set /p name1="enter your name" echo name is: %name1% ) REM it works here set /p name2="enter your name" echo name is: %name2%
thank you
原文:https://stackoverflow.com/questions/3025147
最满意答案
我一直在搜索,发现这个答案有点像我在寻找: https : //stackoverflow.com/a/14058267/4349619
我做了一些调整,现在我的gitignore看起来像这样:
# Django stuff: *.log *.pot local_settings.py # databases *.sqlite3 # Sphinx documentation docs/_build/ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # Distribution / packaging bin/ build/ develop-eggs/ dist/ eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports .tox/ .coverage .cache nosetests.xml coverage.xml # Temporary files *~ # Mr Developer .project .pydevproject # Intellij idea .idea *.iml # Don't know what these are *.sw[po] *.bak *.orig # PyBuilder target/
我认为其中一些是不需要的,但现在还可以。 随意留下建议和改进:)
I have been searching a little and found this answer is kind of what i was looking for: https://stackoverflow.com/a/14058267/4349619
i did some more tweaking and now my gitignore looks like this:
# Django stuff: *.log *.pot local_settings.py # databases *.sqlite3 # Sphinx documentation docs/_build/ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # Distribution / packaging bin/ build/ develop-eggs/ dist/ eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports .tox/ .coverage .cache nosetests.xml coverage.xml # Temporary files *~ # Mr Developer .project .pydevproject # Intellij idea .idea *.iml # Don't know what these are *.sw[po] *.bak *.orig # PyBuilder target/
i think some of these are not needed but it's ok for now. feel free to leave suggestions and enhancements :)
相关问答
更多-
为了构建编译软件包,您需要告诉setup.py的配置步骤以查找包含文件的其他位置。 我相信这可以这样做: python setup.py config --with-includepath=/path/to/your/install/of/python/includes/ 您可能还需要告诉setup.py有关其他文件(如库)的位置,在这种情况下请查看: python setup.py config --help 并查看--libraries和--library-dirs选项。 要更改安装结果包的位置,请 ...
-
我知道了。 确保在MANIFEST.in文件中有完整的路径。 就像是: include smlgui/gui/*.ui include smlgui/gui/assets/*.png 然后通过做一个轮子来测试它 python setup.py bdist_wheel 在build文件夹下,您应该能够看到所有内容。 I got it. Make sure you have the complete path in the MANIFEST.in file. Something like: include ...
-
除了Ned的回答之外还有一些注解(其中涉及核心问题): Distutils不会在site-packages (或Debian / Ubuntu中的dist-packages )中的每个项目子目录中安装Python包和模块:它们直接安装到site-packages ,如您所见。 因此,您的sdist中包含的whyteboard-xx目录将不会以最终的安装形式存在。 这样做的一个暗示是,您应该谨慎的命名您的data_files ,以澄清他们属于哪个项目的方式,因为这些文件/目录直接安装到全局site-packa ...
-
Babel:在调用setup.py install时编译翻译文件(Babel: compile translation files when calling setup.py install)[2022-04-10]
我认为你的要求是完全有效的,我很惊讶似乎没有关于如何实现这一目标的官方指南。 我现在工作的项目也变成了多语言,这就是我所做的: 在setup.cfg ,创建适当的条目,以便可以在没有选项的情况下运行compile_catalog 。 在setup.py ,从setuptools安装命令的子类: setup.py: from setuptools import setup from setuptools.command.install import install class InstallWithComp ... -
它可能很难看,但我这样做是为了强制安装/升级: from pkg_resources import parse_version ## Install numpy if it is not found or too old try: import numpy if parse_version(numpy.__version__) < parse_version('1.10'): print("numpy {} was found but is too old. Upgradi ...
-
而不是这个: my_package\ my_subpackage\ __init__.py deep_module.py __init__.py module.py setup.py 尝试这个: my_package_source\ setup.py README.txt my_package\ my_subpackage\ __init__.py dee ...
-
我一直在搜索,发现这个答案有点像我在寻找: https : //stackoverflow.com/a/14058267/4349619 我做了一些调整,现在我的gitignore看起来像这样: # Django stuff: *.log *.pot local_settings.py # databases *.sqlite3 # Sphinx documentation docs/_build/ # Byte-compiled / optimized / DLL files __pycache__ ...
-
你错过了someapp.django.apps包; 您必须列出该列表中的所有包。 您可以使用setuptools.find_packages()使任务更容易: setup( # ... packages=find_packages(), # ... ) You missed out the someapp.django.apps package; you must list all packages in that list. You can make the task easi ...
-
好吧,我觉得整件事都错了。 'includes' : ['sqlalchemy.dialects.sqlite'] 而不是包,而这似乎已经完成了诀窍。 Well seems I got the whole thing wrong. 'includes' : ['sqlalchemy.dialects.sqlite'] Instead of packages, and that seems to have done the trick.
-
看来你无能为力:-) - 它是用pip源代码硬编码的:-) 如果你尝试使用pip install -e . ,它将调用一个名为parse_editable的方法,该方法将运行此行 : if not os.path.exists(os.path.join(url_no_extras, 'setup.py')): raise InstallationError( "Directory %r is not installable. File 'setup.py' not found." % ...