我们如何在python中异或十六进制数字,例如.我想xor'ABCD'到'12EF'.答案应该是B922.
我使用下面的代码,但它返回垃圾值
def strxor(a, b): # xor two strings of different lengths
if len(a) > len(b):
return "".join(["%s" % (ord(x) ^ ord(y)) for (x, y) in zip(a[:len(b)], b)])
else:
return "".join(["%s" % (ord(x) ^ ord(y)) for (x, y) in zip(a, b[:len(a)])])
key ='12ef'
m1='abcd'
print strxor(key,m1)
Run Code Online (Sandbox Code Playgroud) 我试图用Python 2.7.3 在Ubuntu 10.04(Lucid Lynx)上安装pycrypto2.6 .
我遇到以下错误:
running build
running build_py
running build_ext
running build_configure
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/pratibha/Desktop/pycrypto-2.6':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Traceback (most recent call last):
File "setup.py", line 456, in <module>
core.setup(**kw)
File "/usr/local/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run() …Run Code Online (Sandbox Code Playgroud) 无法解决是什么错误。
django.db.utils.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Run Code Online (Sandbox Code Playgroud)
当我运行以下任何命令时,我一直在获取跟踪
Unhandled exception in thread started by <function wrapper at 0x0000000003DAC4A8>
Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs)
File "C:\Python27\lib\site packages\django\core\management\commands\runserver.py", line 124, in inner_run
self.check_migrations()
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 437, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 52, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Office365 smtp服务器自动发送电子邮件。我的代码以前适用于 gmail 服务器,但不适用于使用 smtplib 的 Python 中的 Office365 服务器。
我的代码:
import smtplib
server_365 = smtplib.SMTP('smtp.office365.com', '587')
server_365.ehlo()
server_365.starttls()
Run Code Online (Sandbox Code Playgroud)
ehlo() 的响应是:(501, '5.5.4 Invalid domain name [DM5PR13CA0034.namprd13.prod.outlook.com]')
此外,.starttls() 引发了SMTPException: STARTTLS extension not supported by server
知道为什么会发生这种情况吗?
首先,我在某处读到我们不应该使用XMLHttpRequest.
其次,我是 Javascript 的新手。
第三,我创建了一个网页来提交电子邮件和密码。
<form method="POST" onsubmit="return check();">{% csrf_token %}
<p><b>Login</b></p>
<input type="email" name="email" placeholder="Email" required></input>
<input type="password" name="password" placeholder="Password" id='new_password' ></input>
<span id='message'>{{msg}}</span>
<button type="submit" onclick="check()" name="Submit"><b>Submit</b></button>
</form>
Run Code Online (Sandbox Code Playgroud)
我的检查功能是
function check() {
document.getElementById('message').innerHTML = "checking";
const url = "https://<hostname/login";
const data = {
'email' : document.getElementById('email').value,
'password' : document.getElementById('password').value
};
const other_params = {
headers : { "content-type" : "application/json; charset=UTF-8" },
body : data,
method : "POST",
mode : "cors"
};
fetch(url, other_params)
.then(function(response) { …Run Code Online (Sandbox Code Playgroud) 我有一个使用硒进行测试的脚本。现在甚至可以使用打开 Google 页面
driver.get(url) # url = Google homepage url
Run Code Online (Sandbox Code Playgroud)
给我以下错误
driver.get("https://my.gumtree.com/login")
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 245, in get
self.execute(Command.GET, {'url': url})
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot determine loading status
from unknown error: missing or invalid 'entry.level'
(Session info: chrome=65.0.3315.3)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.16299 x86_64)
Run Code Online (Sandbox Code Playgroud)
我有 Google chrome 版本 65、Chromedriver 2.35 和 selenium 2.53.1
我根据其他类似问题中提到的解决方案尝试了不同的版本组合(下表中提到),但没有任何效果。
Selenium Chrome Chromedriver
2.53.0 63 2.33
2.53.1 …Run Code Online (Sandbox Code Playgroud) python selenium google-chrome selenium-chromedriver selenium-webdriver
我正在尝试使用 pycrypto++ 在 python 中设计 AES CTR 加密/解密程序。但每次我运行下面的代码时:
decryptor = AES.new(key, AES.MODE_CTR, counter=Counter.new(64, prefix=nonce))
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Traceback (most recent call last):
File "aes-ctr.py", line 3, in <module>
from collections import Counter
ImportError: cannot import name Counter
Run Code Online (Sandbox Code Playgroud)
nonce 是我给的。请帮帮我。我的python版本是2.7.3
我试图将我的线程代码转换为多处理代码.但它给了我错误
Name Error: global name 'multiprocessing' is not defined
Run Code Online (Sandbox Code Playgroud)
安装了多处理,我将其导入
from multiprocessing import *
Run Code Online (Sandbox Code Playgroud)