这是leetcode 26.给定一个排序数组,就地删除重复项,使每个元素只出现一次并返回新的长度.给出一个例子nums = [1,1,2],函数应该返回[1,2].
以下是我的代码.我删除了所有其他副本,只留下其中一个.但是我总是reference binding to null pointer of type 'value_type'在提交时出错.如果有人能帮助我,我将不胜感激!
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int i = 0;
while(i < nums.size() - 1) {
if (nums[i] == nums[i + 1]) {
nums.erase(nums.begin() + i);
}
else i++;
}
return nums.size();
}
};
Run Code Online (Sandbox Code Playgroud) #global variable
_test__x=13
class test:
def __init__(self,x):
self.__x=x
def rex(self):
return __x
d = test(5)
print(d.rex())
Run Code Online (Sandbox Code Playgroud)
如果我运行此代码,它将返回 13 我知道解释器应用了名称修饰,因此变量__x变成了_test__x
但这与全局变量相同。
我尝试使用,self._test__x但没有用
如何访问__x声明的变量__init __.py而不是全局变量?
我使用 Flask jinja2 模板将一个列表列表发送到我的 HTML 页面。我想检查:- 列表中的项目是否属于 str 类型?但得到一个例外
jinja2.exceptions.UndefinedError:“isinstance”未定义
代码如下:-
{% for i in req%}
<tr>
<th scope="row">{{loop.index}}</th>
<td>{{i[1]}}</td>
<td>{{i[24]}}</td>
<td>{{i[49]}}</td>
<td>{{i[53]}}</td>
{% if isinstance(i[86], str) %}
{% for j in i[86].split(",") %}
<ol>
<li>{{i[86]}}</li>
</ol>
{% endfor %}
{% else %}
<td>{{i[86]}}</td>
{% endif %}
</tr>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我能够在 jinja 2 模板中使用split(",")函数并希望使用 pythonisinstance()或。str()
我尝试将健康检查添加到我的撰写文件中,但每当我运行撰写文件时,我都会收到以下错误.
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for balrogadmin: 'healthcheck'
Unsupported config option for balrogagent: 'healthcheck'
Unsupported config option for balrogpub: 'healthcheck'
Unsupported config option for balrogui: 'healthcheck'
Run Code Online (Sandbox Code Playgroud)
我的docker配置是:
docker --version
Docker version 17.03.0-ce, build 3a232c8
docker-compose --version
docker-compose version 1.11.2, build dfed245
Run Code Online (Sandbox Code Playgroud)