小编Lyr*_*ell的帖子

什么是开放“U”模式的非弃用版本

我正在尝试使用以下命令在 python 中读取文本文件:

with open("Keys.txt","rU") as csvfile:
Run Code Online (Sandbox Code Playgroud)

但是,这会产生折旧警告。

DeprecationWarning: 'U' mode is deprecated
Run Code Online (Sandbox Code Playgroud)

这种文本/csv 文件访问模式的非弃用版本是什么。

python deprecated

18
推荐指数
1
解决办法
5717
查看次数

Read Fernet Key Causes ValueError: Fernet key must be 32 url-safe base64-encoded bytes

In this function I am trying to read a Fernet key from a file, or create one if the file doesn't contain a key.

from cryptography.fernet import Fernet
import csv


with open("Keys.txt","rU") as csvfile:
    reader=csv.reader(csvfile)
    KeyFound=0
    print(KeyFound)
    for row in reader:
        try:
            print(row[0])
        except IndexError:
            continue
        if len(row[0])>4:
            print("KEY FOUND")
            KeyFound=1
            print(KeyFound)
            Key=row[0]
            print(Key)
            print(KeyFound)
        else:
            pass
if KeyFound==0:
    Key = Fernet.generate_key()
    print(Key)
    print("Created Key")
    csvfile.close()
#Writing Key to textfile
with open("Keys.txt", "w+") as csvfile:
    headers = ['key']
    writer=csv.DictWriter(csvfile, fieldnames=headers) …
Run Code Online (Sandbox Code Playgroud)

python csv cryptography python-3.x

6
推荐指数
1
解决办法
2万
查看次数

GPG 密钥新密钥但不包含用户 ID

我添加了一个新来源

deb http://httpredir.debian.org/debian buster-backports main contrib
Run Code Online (Sandbox Code Playgroud)

到我的树莓派上的源列表文件。当我更新 sudo apt 来确认更改时,出现以下错误:

sudo apt update
Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Get:2 http://httpredir.debian.org/debian buster-backports InRelease [46.7 kB]
Get:3 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
Err:2 http://httpredir.debian.org/debian buster-backports InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138
Get:4 http://archive.raspberrypi.org/debian buster/main armhf Packages [330 kB]
Reading package lists... Done
W: GPG error: http://httpredir.debian.org/debian buster-backports InRelease: The following signatures couldn't be verified because the public key is not available: …
Run Code Online (Sandbox Code Playgroud)

linux networking key gnupg

5
推荐指数
1
解决办法
1万
查看次数

无法使用 Pycharm 安装 PIL

嗨,我正在尝试使用 Pycharm 安装 PIL。我正在使用 pip 19.1.1

当我尝试安装 PIL 时发生此错误

Collecting PIL

ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
Run Code Online (Sandbox Code Playgroud)

我相信这个错误是由于在版本下拉菜单中没有指定 PIL 的版本。我无法指定要安装的 PIL 版本,因为下拉菜单中没有选项。

python module pip python-imaging-library pycharm

0
推荐指数
1
解决办法
9390
查看次数