变量的二维(Double dimension of a variable)
这是我第一次用Python进行编程(之前我使用过NCL),并且尝试将变量rad_cool和prec的经度维加倍 。 但是我对Python的语法有问题,并得到错误:
IndexError: list assignment index out of range
这是我的代码:
n=np.size(time_sat) m=np.size(lat_sat) l=np.size(lon_sat)*2 prec_double=[[n],[m],[l]] rad_cool_double=[[n],[m],[l]] for j in range(0,720): if(j<=359): rad_cool_double[:][:][j]=rad_cool[:][:][j] prec_double[:][:][j]=prec[:][:][j] else: rad_cool_double[:][:][j]=rad_cool[:][:][j-np.size(lon_sat)] prec_double[:][:][j]=prec[:][:][j-np.size(lon_sat)]
任何人都可以帮助我吗?
干杯,狮子座
It is my first time programming with Python (I used NCL before) and I try to double the longitude dimension of my variables rad_cool and prec. But I have a problem with the syntax of Python and get the error:
IndexError: list assignment index out of range
That's my code:
n=np.size(time_sat) m=np.size(lat_sat) l=np.size(lon_sat)*2 prec_double=[[n],[m],[l]] rad_cool_double=[[n],[m],[l]] for j in range(0,720): if(j<=359): rad_cool_double[:][:][j]=rad_cool[:][:][j] prec_double[:][:][j]=prec[:][:][j] else: rad_cool_double[:][:][j]=rad_cool[:][:][j-np.size(lon_sat)] prec_double[:][:][j]=prec[:][:][j-np.size(lon_sat)]
Can anyone help me with that?
Cheers, Leo
原文:https://stackoverflow.com/questions/42991256
最满意答案
我已经为Notepad ++安装了XML Tools插件 。
然后使用“插件 - > XML工具 - >漂亮的打印(仅限XML - 带换行符)”,这解决了我的格式问题。
I have installed the XML Tools plugin for Notepad++.
Then used the "Plugins --> XML Tools --> Pretty print (XML only - with line breaks)" and that solved my formatting problem.
相关问答
更多-
职称电脑初级[2023-01-21]
notepad -
Notepad ++和自动完成(Notepad++ and autocompletion)[2023-06-04]
编辑cpp.xml文件并添加您想要的所有关键字和功能描述。 只需确保按字母顺序添加它们,否则它们将不会显示。 另一个选项是在“设置” - >“首选项”对话框的“ 自动完成”区域中选择“ 函数”和“单词完成 ” 。 NPP将建议当前文件中以您键入的前N个字母开头的每个“单词”(在“自动完成”控件中选择N的值)。 Edit the cpp.xml file and add all the keywords and function descriptions you'd like. Just make sure ... -
在搜索对话框中设置搜索模式“正则表达式”,然后使用以下正则表达式: Members: [^0] Set search mode "regular expression" in the search dialog, then use the following regular expression: Members: [^0]
-
Notepad ++ RegExp(Notepad++ RegExp)[2023-09-11]
你可以通过两次通过。 第一遍:用空字符串替换\s+ ,就像你做的那样。 第二关: (Item\.?)(\d+)\.?(.*?)(?=Item\.?\d+|\Z) "$1 $2":"$3", .*? 是懒惰的 ,它会尝试匹配尽可能少的字符,但是前瞻(?=Item\d+\.|\Z)强制它匹配,直到它跟着另一个Item\d+\. 或字符串的结尾( \Z )。 You can do this with two passes. First pass: replace \s+ with an empty strin ... -
相当简单:user-folder中有一个session.xml文件,用于保存打开的文件并包含指向它们的链接。 如果文件尚未保存,则它也存储在用户文件夹中。 Windows中的用户文件夹位于: C:\Users\your user\AppData\Roaming\Notepad++ 有session.xml。 在任何编辑器中打开它,您会看到打开的文件。 未保存的文件指向备份文件夹,文件名为new 1 @ 2015-10-05_114609希望有所帮助。 Fairly simple: There's a se ...
-
只需按Ctrl + F或从菜单 - 搜索 - >查找,然后在搜索字段中键入您的字符串。 在方向选择Up,它将从结束开始。(确保在所有这些之前你没有将鼠标指向文本的任何位置,或者它在文件中的第一个字符之前。) Just press Ctrl+F or from the Menu - Search -> Find and then type your string in search field. In direction choose Up, and it will start from the end.(M ...
-
我已经为Notepad ++安装了XML Tools插件 。 然后使用“插件 - > XML工具 - >漂亮的打印(仅限XML - 带换行符)”,这解决了我的格式问题。 I have installed the XML Tools plugin for Notepad++. Then used the "Plugins --> XML Tools --> Pretty print (XML only - with line breaks)" and that solved my formatting pro ...
-
这是因为您的MATLAB编辑器设置为使用等宽字体,例如Courier(即所有字符设计为具有完全相同宽度的字体),但您的Notepad ++不是。 在Notepad ++中,您可以使用菜单Settings - > Style Configurator设置字体。 从语言列表中选择“MATLAB”(或者实际上您可能希望选择“全局样式”,为所有语言执行此操作),并将字体设置为等宽字体,如Courier。 或者,您可以下载更现代的编程字体,如Consolas,ProFont,Monofur,Proggy或Incons ...
-
Notepad ++加入缩进行(Notepad++ Join indented lines)[2022-04-27]
我不知道这个插件。 但这可以分两步完成。 将所有前导空格和制表符替换为空 选择行并按ctrl + j 搜索字符串: ^ [\ s \ t] * I don't know any plugin for this. But this can be done in two steps. Replace all leading space and tab to empty Select the lines and hit ctrl + j Search String : ^[\s\t]* -
正如评论中指出的那样,它们通常被称为代码片段,你会在SnippetPlus插件中找到对它们的良好支持。 As pointed out in the comments, they're often called code snippets, and you'll find good support for these in the SnippetPlus plugin.