I want to transform the list ["A","B","A","A","B"] to the list ["AB","BA","AA","AB"].
I have tried to define a new list in which the first element is deleted and then add the strings of the lists together. After which I plan to delete the last element of the new list to get the result.
lista = sequences
lista.pop(0)
print(lista)
for x in range(sequences):
mc =sequences[x]+lista[x]
Run Code Online (Sandbox Code Playgroud)
But all I get is
TypeError: 'list' object cannot be interpreted as an integer
Any help …
我正在使用 JWT 令牌,我使用以下方法创建了公共和私有 JWT 令牌:
ssh-keygen -t rsa -b 4096
Run Code Online (Sandbox Code Playgroud)
已在给定路径上成功创建两个(公共和私有)文件。
当我尝试从 python 脚本访问它时,如下所示:
读取文件
script_dir = os.path.dirname(__file__)
file_path = os.path.join(script_dir, '../../instance/jwt-key.pub')
with open(file_path, 'r') as keys:
jwt_keys = keys.read()
Run Code Online (Sandbox Code Playgroud)
主要.py
def loginM(email, password):
user_reg = Registration.query.filter_by(email=email).first()
if bcrypt.check_password_hash(user_reg.password, password):
identity = {'first_name': user_reg.first_name, 'exp': time.time() + 1440}
token = jwt.encode(identity, jwt_keys, algorithm='RS256').decode('utf-8')
print(token)
return dict(token=token)
else:
return dict(Unsucessful="Invalid username and password")
Run Code Online (Sandbox Code Playgroud)
当我尝试打印令牌时,出现这样的错误。
“_RSAPublicKey”对象没有属性“sign”
当我直接打印 jwt_keys 时,它正在打印令牌。
如果在控制台中执行与此相同的过程,则它可以正常工作。
命令代码。
这里 jwt 公共文件和私有文件位于同一文件夹中:
import jwt
payload = {'mae':'sao'}
key = open('jwt_key').read() …Run Code Online (Sandbox Code Playgroud) 我想"Projects.csv"从这个网站自动下载一个 CSV 文件:
https://www.vcsprojectdatabase.org/#/projects/st_/c_/ss_0/so_/di_/np_
可以通过单击 CSV 图标手动下载 CSV,但我不确定如何在 python 中自动下载并将 CSV 文件本地存储在我的驱动器上。
到目前为止,我已经尝试通过 chrome 开发人员控制台检查按钮元素,以在“网络”选项卡中找到正确的 url,如下所示?
https://www.vcsprojectdatabase.org/services/publicViewServices/fetchProjectsExport
但我不确定这个 URL 是否应该在末尾包含文件名,如下所示:
https://www.vcsprojectdatabase.org/services/publicViewServices/fetchProjectsExport/Projects.csv
这是我尝试过的,但它只是写了一个空白文件:
import requests
url = 'https://www.vcsprojectdatabase.org/services/publicViewServices/fetchProjectsExport/Projects.csv'
r = requests.get(url)
with open('a.csv', 'wb') as f:
f.write(r.content)
Run Code Online (Sandbox Code Playgroud)
如何让 CSV 文件正确下载和保存?