如何在 Linux 中使用 Bash 登录网站。例如登录到StackOverflow我尝试了许多不同的方法,如下所示,但没有任何效果。
wget --save-cookies cookies.txt --keep-session-cookies --post-data="username=blahblah&password=blahblahblha" "https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2f"
Run Code Online (Sandbox Code Playgroud)
或者
curl --user myusername:mypassword https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2f -v
Run Code Online (Sandbox Code Playgroud)
我尝试使用 Chrome 检查元素以复制curl请求,但它不起作用(可能它取决于 cookie 并且仅在特定时间段内有效)。
请注意,我需要使用用户名和密码而不是 cookie 登录。
我在下面有以下代码,我知道它__new__用于创建类的实例,并且该__init__方法用于初始化对象的值。
是__init__当您返回基类的一个实例,只叫什么名字?
我想要的是返回另一个名为 class A 的类的实例。有没有办法__init__配置 class A 的实例?
# Python program to
# demonstrate __new__ method
# class whose object
# is returned
class GeeksforGeeks(object):
def __str__(self):
return "GeeksforGeeks"
# class returning object
# of different class
class Geek(object):
def __new__(cls):
return GeeksforGeeks()
def __init__(self):
print("Inside init")
print(Geek())
Output:
GeeksforGeeks
Run Code Online (Sandbox Code Playgroud) 我的问题很简单,我在互联网上搜索这个问题,但没有找到任何有用的东西。
list有人能告诉我获得所有 s 的最简单方法是什么吗bot.guilds id?也许你们知道如何将其转换为整数?这将是最好的。
我正在尝试使用 PyTorch 制作 AI,但出现以下错误:
RuntimeError: gather_out_cpu(): Expected dtype int64 for index
Run Code Online (Sandbox Code Playgroud)
这是我的功能:
def learn(self, batch_state, batch_next_state, batch_reward, batch_action):
outputs = self.model(batch_state).gather(1, batch_action.unsqueeze(1)).squeeze(1)
next_outputs = self.model(batch_next_state).detach().max(1)[0]
target = self.gamma * next_outputs + batch_reward
td_loss = F.smooth_l1_loss(outputs, target)
self.optimizer.zero_grad()
td_loss.backward(retain_variables = True)
self.optimizer.step()
Run Code Online (Sandbox Code Playgroud)