我试图完成以下操作,如果我有两个列表,L1和L2,我希望结果(R)是来自L1的L2的"减法".
例:
L1 = [1,2,3]
L2 = [2,3,4,5]
R = [1]
Run Code Online (Sandbox Code Playgroud)
我能够做到这一点,但我不知道_和之间有什么区别[_].
如果我这样做:
diferencia([],_,[]).
diferencia([X|Tail],L2,R):-
member(X,L2),
diferencia(Tail,L2,R).
diferencia([X|Tail],L2,[X|R]):-
not(member(X,L2)),
diferencia(Tail,L2,R).
Run Code Online (Sandbox Code Playgroud)
它有效,如果我这样做,它会给我错误:
diferencia([],[_],[]).
diferencia([X|Tail],L2,R):-
member(X,L2),
diferencia(Tail,L2,R).
diferencia([X|Tail],L2,[X|R]):-
not(member(X,L2)),
diferencia(Tail,L2,R).
Run Code Online (Sandbox Code Playgroud)
我会假设一个包含任何内容的列表[_]应该可以工作,因为L2将始终是一个列表.
moodle平台中管理员登录的密码丢失.
我可以访问phpMyAdmin.
我去了mdl_user表,在那里我可以看到或编辑这个表.
我该怎么办?我可以将管理员输入的密码和密钥更改为已知密码,还是只添加管理员用户更简单?
怎么会这样?
我写了这个非常简单的PHP登录系统:
<?php
session_start();
$error = '';
if (isset($_POST['username']) && isset($_POST['password']))
{
if ($_POST['username'] == 'user' && $_POST['password'] == 'pass')
{
$_SESSION['client'] = 'ok';
Header ("location: /kit/kit/index.php");
}
else
{
$error = 'Usuario o contraseña incorrectos.';
}
}
?>
Run Code Online (Sandbox Code Playgroud)
不必担心漏洞问题,它不会保护任何有价值的东西。
在每个.php页面中,我添加:
<?php
session_start();
if (!isset($_SESSION['client']) || $_SESSION['client'] != 'ok')
{
Header ("location: /kit/index.php");
die();
}
?>
Run Code Online (Sandbox Code Playgroud)
这样可以很好地保护.php会话。
问题在于这不能保护文件。
我的意思是如果直接去:
东西/其他/file.zip
无论您是否登录,它将下载它。
我希望这个问题很清楚,如果不能,请提出!
我无法真正理解我做错了什么,因为当我在"小规模"尝试时它正在那里工作.
我有一个名为的班级 Play()
我是这样的:
class Play():
def __init__(self):
file = open("/home/trufa/Desktop/test", "r")
self.word = random.choice(file.readlines()).rstrip()
self.errAllowed = 7
self.errMade = 0
self.errList = []
self.cheatsAllowed = 2##chetas not incrementing
self.cheatsMade =0
self.wordList = ["*"]*len(self.word) ##this one is the one I want to have available in another class
Run Code Online (Sandbox Code Playgroud)
...
然后我有另一个叫做的课 Score()
class Score(Play):
def __init__(self):
self.initialScore = 0
def letterGuess(self):
self.initialScore += 1
return self.errList
Run Code Online (Sandbox Code Playgroud)
...
我实例化了两个:
game = Play()
points = Score()
Run Code Online (Sandbox Code Playgroud)
如果我这样做:
print points.letterGuess()
Run Code Online (Sandbox Code Playgroud)
它给了我一个错误:
Traceback (most recent call …Run Code Online (Sandbox Code Playgroud) 我有一个createCategoryMeny(x)在点击时调用的画布.
这个函数只创建一个Toplevel()窗口,
def createCategoryMenu(tableNumber):
##Not interesting below:
categoryMenu = Toplevel()
categoryMenu.title("Mesa numero: " + str(tableNumber))
categoryMenu.geometry("400x400+100+100")
categoryMenu.focus()
categoryMenu.grab_set()
Label(categoryMenu, text="Elegir categoria \n Mesa numero: " + str(tableNumber)).pack()
## RELEVANT CODE BELOW:
listbox = Listbox(categoryMenu, width=50, height=len(info.listaCategorias))
listbox.pack(pady=20)
for item in info.listaCategorias:
listbox.insert(END, item)
listbox.selection_set(first=0)
##My attempt to solve it
callback = lambda event, tag= "ThisShouldBeTheSelected!!": do(event, tag)
listbox.bind("<Double-Button-1>", callback)
Run Code Online (Sandbox Code Playgroud)
那么do函数:
def do(event, tag):
print tag
Run Code Online (Sandbox Code Playgroud)
这成功地打印了"ThisShouldBeTheSelected !!"``.
这就是我完全陷入困境的地方.
我无法获得双击元素(选定的元素).
我想传递它tag=.
我试过了:
listbox.curselection()
Run Code Online (Sandbox Code Playgroud)
总是打印 ('0',) …
至少根据我的经验,这是一个非常奇怪的错误.
我已经制作了该网站的测试版本,因此您可以在这里看到它.
重现步骤:
进入该网站,哟看到#thelist它应该正常:

当你做一个简单的刷新时我会在Windows机器上这么Ctrl+ R或者F5.
现在#thelist将改变它的立场:
修复这个问题的主要问题是,当我尝试检查元素时,它会回到正确的位置......
另请注意,如果您执行硬刷新Ctrl+ Shift+ R或Ctrl+,F5则元素将返回到正确的位置.
这怎么可能,是什么导致了这个?怎么解决?
我试图用jquery选择div及其内容.
div看起来像这样:
<div class="fav-list" id="149656222">
<ul>
<li>hai</li>
<li>hooy</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
和我的代码
alert($('#149656222').html());
Run Code Online (Sandbox Code Playgroud)
这只显示了这么多:
<ul>
<li>hai</li>
<li>hooy</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我需要选择整个div,我需要做什么呢?
我正在尝试执行一个简单的命令:
p = subprocess.Popen("nvm use 0.12.7", cwd="../tags/" + "2.0.4", stdout=subprocess.PIPE, shell=True)
stdout, stderr = p.communicate()
Run Code Online (Sandbox Code Playgroud)
我越来越:
/bin/sh: 1: nvm: not found
Run Code Online (Sandbox Code Playgroud)
我不确定为什么会发生这种情况,它通常适用于其他命令,nvm 命令有什么特别之处?
假设我有一个看起来像这样的传奇:
export function* incrementAsync(action) {
try {
const res = yield call(Api.signin.create, action.payload);
yield put({
type: USER_SIGN_IN_FETCH_SUCCESS,
payload: res.data.auth
};
} catch (e) {
yield put({ type: USER_SIGN_IN_FETCH_ERROR_NETWORK });
}
}
Run Code Online (Sandbox Code Playgroud)
这次尝试取得了成功,但这并不意味着用户实际上已经登录:
res.data.auth.error 可能是真的
我的问题是我是否应该做以下事情:
if (//user was succesfully logged in)
yield put(//user was successfully logged in)
else if //wrong username
yield put(//wrong username)
else if //wrong password
yield put(//wrong password)
Run Code Online (Sandbox Code Playgroud)
还是我应该只有一个代表成功,一个代表错误,并在化简器中分析逻辑并相对于响应数据建立存储?
我正在尝试使用 Cypress 对前端和后端调用进行useSession()存根getSession()。
存根函数似乎不会替换函数或被调用:
我正在尝试这样做:
const client = require("next-auth/react")
....
....
cy.stub(client, "getSession").returns({
user: {
name: "xxx",
email: "xxx",
image: "xxx",
},
expires: "2022-07-08T09:49:47.602Z",
})
cy.stub(client, "useSession").returns({
user: {
name: "xxx",
email: "xxx",
image: "xxx",
},
expires: "2022-07-08T09:49:47.602Z",
})
cy.visit(`/draft/cl45ip2d600379as17epvu6ti`)
Run Code Online (Sandbox Code Playgroud)
我试过用谷歌搜索它,但大多数人似乎使用 jest 而不是 cypress,而且似乎没有很多文档,我不知道如何继续。
我不确定这是否相关,但对 getSession 的调用是由客户端对 api 的 http 请求触发的。
python ×3
jquery ×2
php ×2
reactjs ×2
admin ×1
attributes ×1
css ×1
cypress ×1
html ×1
inheritance ×1
instance ×1
javascript ×1
list ×1
listbox ×1
moodle ×1
mysql ×1
next.js ×1
nvm ×1
passwords ×1
phpmyadmin ×1
prolog ×1
protection ×1
redux ×1
redux-saga ×1
refresh ×1
session ×1
sinon ×1
stub ×1
subprocess ×1
tk-toolkit ×1
tkinter ×1