我正在尝试通过 launch.json 将参数传递给我的 Python 程序,我的参数之一需要特殊字符,因为它是密码(我计划添加更安全的方式来输入密码,但这不是重点)。
这是我的launch.json(密码已更改但仍带有特殊字符)
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"args": [
"-u",
"camera@iot-project.com",
"-p",
"Y^bKKiUPu!fM6!dBsvnALmuXbP6fqT$d"
],
"console": "integratedTerminal"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我将密码参数设置为 时"'Y^bKKiUPu!fM6!dBsvnALmuXbP6fqT$d'",它实际上将单引号传递到 Python 程序中,这不是我想要的(在带有单引号的终端中运行程序有效)。
这是我的 Python 程序:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of …Run Code Online (Sandbox Code Playgroud) 我无法使用 pip 命令。每次我尝试时都会遇到以下错误:
NameError: name 'pip' is not defined
Run Code Online (Sandbox Code Playgroud)
我正在使用 CMD 和 Python 3.8。我几乎可以肯定那C:\python\scripts是我的道路。然而 pip 命令仍然无法满足我的能力。我读过几篇关于其他遇到此问题的人的文章和主题,但这些解决方案仍然无法帮助我。
从 CMD 复制粘贴:
C:\Windows\System32>py
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pip' is not defined
Run Code Online (Sandbox Code Playgroud) 我最近了解了签名提交并推荐它们。我们可以使用 本地签署提交git commit -S。之后我阅读了 git 手册页,其中有一个名为-s(用作git commit -s)的选项,它表示该选项对提交进行签名。当我查找时,-S它说它使用 GPG 密钥签署了提交。
我正在 GitHub 中使用 GPG 密钥设置签名提交。这在推送时有什么不同吗?或者在推送到远程时是否相同?
我想创建一个函数,-在 UUID 字符串的位置 8、12、16、20 上添加一个。
例子:
Original: 76684739331d422cb93e5057c112b637
New: 76684739-331d-422c-b93e-5057c112b637
Run Code Online (Sandbox Code Playgroud)
我不知道如何将它放置在看起来不像意大利面条代码的字符串中的多个位置。
我有一堂课,看起来像这样:
class Product(BaseModel):
code: str = ...
discription_one: str = ...
famille: FamilleProduct
sou_famille: SouFamileProduct
parent: ParentProduct
sou_parent: SouParentProduct
group: GroupProduct
sou_group: SouGroupProduct
reference: Optional[str] = ''
oem: Optional[str] = ''
other_code: Optional[str] = ''
discription_two: Optional[str] = ''
discription_three: Optional[str] = ''
remarque: Optional[str] = ''
marque: Marque
origine: Country
unite: UniteProduct
code_sh: ShCode
numbre_serie: NumbreSerie
qr_code: QrProduct
status: StatusProduct
product_visible: bool = True
product_loocked: bool = False
product_hided: bool = False
location: LocationProduct
last_prix_achat: float = 0.00
pmp_achat: …Run Code Online (Sandbox Code Playgroud) 有没有办法给flake8添加自定义规则?
这里有一堆规则https://lintlyci.github.io/Flake8Rules/但我在 flake8 的 git 仓库中找不到规则的源代码。
我想写一个自定义规则。
我想安装yq并编辑 Docker 容器上的一些 yaml 文件。
FROM python:3
RUN apt-get update
RUN apt-key adv --keyserver keyserver.ubuntu.com --keyserver-option http-proxy=http://xxxxxx.com:9999 --recv-keys CC86BB64
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:rmescandon/yq
RUN apt update
RUN apt install yq -y
Run Code Online (Sandbox Code Playgroud)
https://github.com/mikefarah/yq#on-ubuntu-1604-or-higher-from-debian-package
=> => transferring dockerfile: 486B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3 0.0s
=> CACHED [1/7] FROM docker.io/library/python:3 0.0s
=> [2/7] RUN apt-get update 2.7s
=> [3/7] …Run Code Online (Sandbox Code Playgroud) 我的路线:
@router.get('/check/{value}', status_code=200)
def ranks_check(value: BasicInput = Depends()):
"""
Test endpoint
"""
return value
Run Code Online (Sandbox Code Playgroud)
我的型号:
class BasicInput:
"""
Get Confidence to score Input class
"""
value: int
@validator('value')
def check_if_value_in_range(cls, v):
if not 0 < v < 1000001:
raise ValueError('Value Exceeded Limit')
Run Code Online (Sandbox Code Playgroud)
我需要做什么:
我需要验证输入并在出现 ValueError 时引发 HTTP 400。
我知道我可以使用 Pydantic 的类型完成整数验证,并在路由函数本身中Field进行运行。check_if_value_in_range我正在寻找使用该模型的解决方案。
我有一个 Docker 映像,其中包含一个 Python 应用程序,作为部署在 Kubernetes 中运行,我想向该应用程序传递一些数据。我使用了环境变量,但我想使用注释,但我不知道如何阅读它们,我看到有V1ObjectMeta一个名为的字段annotations,但我有点不知道如何调用它。
例如:
如果我的 Pod 有这个:
template:
metadata:
annotations:
foo: "var"
Run Code Online (Sandbox Code Playgroud)
如何foo: var使用 Kubernetes 库使用 pod 内运行的 python 程序进行读取?
python ×7
python-3.x ×2
debian ×1
docker ×1
fastapi ×1
flake8 ×1
git ×1
git-commit ×1
git-sign ×1
kubernetes ×1
pip ×1
pydantic ×1
terminal ×1
uuid ×1
yq ×1