我被cs圈问题困住了如何让Z变成A 下一个字母
x =input()
x=x.upper()
x=chr(ord(x) + 1)
print(x)
Run Code Online (Sandbox Code Playgroud)
我怎样才能把z变成A?
当尝试使用SQLAlchemy v1.4.15 中的方法NotImplementedError: This method is not implemented for SQLAlchemy 2.0.删除表时,我收到一个, 。delete
from sqlalchemy import Column, Integer, MetaData, String, Table, create_engine, delete
engine = create_engine("sqlite+pysqlite:///:memory:", echo=True, future=True)
metadata = MetaData()
user = Table(
"users", metadata, Column("id", Integer, primary_key=True), Column("name", String)
)
metadata.create_all(engine)
engine.execute(user.delete()) # leading to Traceback
# NotImplementedError: This method is not implemented for SQLAlchemy 2.0.
Run Code Online (Sandbox Code Playgroud) 我刚刚安装了一个Ubuntu仿生实例。它预装了cairo 1.14.6。我至少需要cairo 1.15.4才能使weasyprint正常工作。不幸的是,即使在安装了最新的cairo之后,python仍然会选择旧的库。任何线索,我将不胜感激。
# Install weasyprint dependencies
sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
# Check cairo lib version, prints "1.15.10-2ubuntu0.1"
dpkg -l '*cairo*'
# Install weasyprint
pip3 install weasyprint
# Test cairo version catch by python, still prints "1.14.6"
python3 -c "import cairocffi; print(cairocffi.cairo_version_string())"
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用这个GAE Flask教程.我相信我完全遵循了它,我从Github下载了代码,所以没有错别字.
当我启动dev server(dev_appserver.py app.yaml)并转到http:// localhost:8080/form时,我收到此错误:
Traceback (most recent call last):
File "/Users/.../google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/.../google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Users/.../google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/.../GIT/TEMP/main.py", line 19, in <module>
from flask import Flask, render_template, request
File "/Users/.../GIT/TEMP/lib/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Users/.../GIT/TEMP/lib/werkzeug/__init__.py", line 151, in <module>
__import__('werkzeug.exceptions')
File "/Users/.../GIT/TEMP/lib/werkzeug/exceptions.py", line 71, in …Run Code Online (Sandbox Code Playgroud) 下面是我的代码,我正在使用:
with open(r'C:\Users\Manish\Desktop\File5.txt', 'r') as f:
fo = f.read(20)
print(fo)
f.seek(20,1)
fo = f.read(20)
print(fo)
Run Code Online (Sandbox Code Playgroud)
但它没有从当前位置获取下一行,而是反复向我显示错误。我的代码问题出在哪里?
我是 Python 初学者。这里我尝试使用 JSON.load 来解析 JSON 字符串。使用 json.dumps 时,我收到以下输出:
{
"events": [
{
"sourceip": "10.10.10.1",
"destinationip": "127.0.0.1"
},
{
"sourceip": "10.10.10.2",
"destinationip": "127.0.0.1"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我正在对此应用 json.loads 函数,以便稍后将它们用于另一个函数。但是,当在结果上使用 json.loads 时,它会将所有双引号替换为单引号,如下所示:
{'events': [{'sourceip': '10.10.10.1', 'destinationip': '127.0.0.1'}, {'sourceip': '10.10.10.2', 'destinationip': '127.0.0.1'}]}
Run Code Online (Sandbox Code Playgroud)
如何使用 json.loads 而不将双引号替换为单引号。
谢谢。
SQLAlchemy 1.4.17我正在尝试在 pytest 中进行简单的查询
def test_first():
engine = create_engine(settings.SQLALCHEMY_DATABASE_URI)
result = engine.execute(text("SELECT email FROM user"))
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误
Exception has occurred: MissingGreenlet
greenlet_spawn has not been called; can't call await_() here. Was IO attempted in an unexpected place? (Background on this error at: http://sqlalche.me/e/14/xd2s)
File "/Users/mattc/Development/inference/server/inference_server/app/tests/test_01_user.py", line 27, in test_first
result = engine.execute(text("SELECT email FROM user"))
Run Code Online (Sandbox Code Playgroud)
不知道为什么?有什么建议么?
我有一个较旧的 Python 项目,它使用标准 IMAP 机制从邮箱检索电子邮件等进行处理。不幸的是,随着 MS365 现在淘汰非 OAuth2 和非现代身份验证,我必须尝试编写一个不依赖用户凭据但可以像使用 OAuth2 的其他用户一样完全访问身份验证等的应用程序。
我已经获取了 MSAL 库部分,并且可以从远程获取访问令牌 - 该应用程序配置了使用客户端密钥登录的工作流,并且可以访问所有用户的所有 EWS 以及应用程序权限中的所有 IMAP.UseAsApp。不过,我可能通过应用程序集成错误地请求了信息。
该应用程序正在使用 Azure AD 中分配给它的以下权限进行操作:
所述应用程序通过共享秘密而不是证书进行身份验证。
我们正在拉取 Outlook 范围,因为我们想要使用 Office 365 Exchange Online 的 IMAP 范围,并通过此令牌和 oauth 使用具有 IMAP 身份验证的内容,而且我不相信 MIcrosoft Graph API 具有任何可用的 IMAP 身份验证端点机制,
下面基本上是我尝试将 MSAL OAuth2 与 Azure AD 中配置的应用程序链接起来以获得工作调用的示例imap.authenticate,至少弄清楚如何使用不记名令牌完成 OAuth2 部分:
import imaplib
import msal
import pprint
import base64
conf = {
"authority": "https://login.microsoftonline.com/TENANT_ID",
"client_id": "APP_CLIENT_ID",
"scope": ["https://outlook.office.com/.default"],
"secret": "APP_SECRET_KEY",
"secret-id": "APP_SECRET_KEY (for documentation …Run Code Online (Sandbox Code Playgroud) 当我尝试导入 psycopg2 时,收到以下错误消息:
ImportError: dlopen(/opt/homebrew/lib/python3.10/site-packages/psycopg2/_psycopg.cpython-310-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/postgresql/lib/libpq.5.dylib
Referenced from: /opt/homebrew/lib/python3.10/site-packages/psycopg2/_psycopg.cpython-310-darwin.so
Reason: tried: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libpq.5.dylib' (no such file), '/opt/homebrew/Cellar/postgresql@14/14.5_3/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libpq.5.dylib' (no such file)
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个错误?
我创建一个简单的Web API,与flask和sqlalchemy与marshmallow为串行,这里是UserModel。
class UserModel(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key = True)
username = db.Column(db.String(120), unique = True, nullable = False)
password = db.Column(db.String(120), nullable = False)
user_role = db.Column(db.String(10), nullable = False)
access_token = db.Column(db.String(120), unique = True, nullable = True, default='as' )
refresh_token = db.Column(db.String(120), unique = True, nullable = True, default='as' )
Run Code Online (Sandbox Code Playgroud)
和模式,
class UserSchema(Schema):
username = fields.Str()
password = fields.Str()
user_role = fields.Str()
access_token = fields.Str()
refresh_token …Run Code Online (Sandbox Code Playgroud) python ×9
python-3.x ×2
sqlalchemy ×2
apple-m1 ×1
cairo ×1
flask ×1
imap ×1
json ×1
macos ×1
marshmallow ×1
oauth-2.0 ×1
psycopg2 ×1
string ×1
ubuntu ×1
weasyprint ×1
werkzeug ×1