通过Windows命令行运行Python脚本(Running Python scripts through the Windows Command Line)
我刚开始使用Mark Luts的Learning Python学习Python 。 在他的书中,他提供了一个通过Windows shell调用的简单脚本示例。 在示例中,他调用如下:
C:\code> python script1.py
我已经离开并修改了我的机器上的环境变量,以便我可以打电话
C:\User\Example> python
打开翻译,我也可以打电话
C:\User\Example> script1
运行我编写并放在我想要的目录中的脚本。 我的问题是我不能打电话
C:\User\Example> python script1.py
在我的命令行中,就像他在书中所做的那样。 他提到了一些关于PYTHONPATH环境变量的内容,但是,我的机器上没有这个变量。 我只有'路径','TEMP'和'TMP'。 特别是,当我尝试拨打这样的电话时,我得到了错误
python: can't open file 'script1.py': [Errno 2] No such file or directory
为了让这种命令在命令行上正常工作,我该怎么办?
I've just started learning Python using Learning Python by Mark Luts. In his book he offers an example of a simple script that is called through the Windows shell. In the example, he calls is as follows:
C:\code> python script1.py
I've gone and modified the Environment Variables on my machine so that I can call
C:\User\Example> python
to open up the interpreter and I can also call something like
C:\User\Example> script1
to run a script that I've written and placed in my desired directory. My issue is that I can not call
C:\User\Example> python script1.py
in my command line the same way he does in the book. He's mentioned something about a PYTHONPATH Environment Variable, however, this variable isn't present on my machine. I only have 'path', 'TEMP', and 'TMP'. Particulary, when I try to make such a call I get the error
python: can't open file 'script1.py': [Errno 2] No such file or directory
What do I have to do in order to get this sort of command to work properly on the command line?
原文:https://stackoverflow.com/questions/43452604
最满意答案
解决了。 需要实施
@Override public int getCount() { return paisesFiltrado.size(); }
Solved. Need to implement
@Override public int getCount() { return paisesFiltrado.size(); }
相关问答
更多-
自定义getFilter在android中的自定义ArrayAdapter(Custom getFilter in custom ArrayAdapter in android)[2019-10-27]
您遇到问题,主要是因为您正在使用自定义对象。 如果你传递一个String或者int值给数组适配器,它就知道如何过滤它。 但是,如果你传递自定义对象的默认过滤器实现不知道如何处理。 虽然目前还不清楚你在过滤器中想要做什么,但我建议你遵循以下步骤。 正确实施ListTO ,尽管它现在与您的目标无关 实施自定义过滤器 返回你的过滤器 实施自定义过滤器 首先你需要做的是,从你的阵列适配器implements Filterable 。 其次,提供你的Filter实现 Filter myFilter = new Fil ... -
onClickItem ListView自定义ArrayAdapter Android Studio(onClickItem ListView custom ArrayAdapter Android Studio)[2022-02-28]
首先使您的类Parcelable或Serializable您需要将ItemClickListener添加到listview listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView> adapterView, View view, int position, long id) { ... -
我有过滤器被应用到自定义ArrayAdapter。 显然这会干扰从适配器本身添加和删除项目? 我将这段代码添加到我的方法中,现在它正在工作: if(appState.favoriteAdapter != null && realmFilter != null) { appState.favoriteAdapter.getFilter().filter(realmFilter.getText().toString()); } 如果有人能解释为什么这很重要,我很乐意。 我认为过滤器是为了在适配器中选 ...
-
无法在ListView上的自定义ArrayAdapter中获取选定项目索引(Can't get Selected Item Index in custom ArrayAdapter on my ListView)[2023-07-31]
尝试使用这一行代码: lv = (ListView) findViewById(R.id.listView1); lv.setAdapter(new myProductAdapter(setupArrayProductList((ArrayList) ProductList), OrderFirstGridPage.this)); lv.setSelector(R.drawable.selector_for_position_list); lv. ... -
Android自定义ArrayAdapter只有2个ViewHolders(Android custom ArrayAdapter with only 2 ViewHolders)[2023-12-03]
了解convertView特性,您必须确保在重新使用convertView之前重置所有可更改UI元素的样式,只有在每行基础上更改视图上的样式(颜色等)时才需要这样做。 因此,如果您确保始终执行' colorTextViews(position,holder) '(将其置于此' if condition '之外)根据当前数据状态设置正确的颜色,它将按您希望的方式工作。 或简化如下: Answer correctAnswer = ...; holder.question.setText(dat ... -
这是工作适配器代码 public class RowAdapter extends ArrayAdapter
{ private final Activity _context; private final ArrayList
rows; public class ViewHolder { EditText RowNo; EditText RowText; } public RowAdapter(Act ...
-
我认为你混淆了片段和布局。 您的setContentView正在加载此XML文件activity_main 看起来像ListView lines_list_view在fragment_lines 因此,修复该部分,将ListView添加到activity_main或将fragment_lines设置为ContentView并再次检查。 I think you are confusing fragments and layouts. Your setContentView is loading this XM ...
-
解决了。 需要实施 @Override public int getCount() { return paisesFiltrado.size(); } Solved. Need to implement @Override public int getCount() { return paisesFiltrado.size(); }
-
你得到的错误是因为你正在调用super(context, R.layout.custom_listview, fieldNames, fieldValues); 在你的构造函数上,而没有这样的构造函数,它为ArrayAdapter类提供了两个String[]参数。 您应该在这里查看ArrayAdapter的文档,并找到适合您的子类的构造函数。 例如: public CustomListViewAdapter(Context context, String[] fieldNames, String[] fie ...
-
如果有静态值。 为什么不使用switch语句。 例如: switch(position) { case 0: imageView.setImage(R.drawable.image1); break; . . . . case 4: imageView.setImage(R.drawable.image5); break; } If there are static values. Why you don't use switch statement. For ex ...