gpt4 book ai didi

python - python 的新手问题,脚本在其他操作系统上工作正常

转载 作者:太空宇宙 更新时间:2023-11-04 10:24:33 24 4
gpt4 key购买 nike

我正在使用带有 python 的机器人在网站上创建帐户。当我在安装了 python 的 Windows 机器上使用它时,它工作正常。我昨天买了一个 linux VPS(Ubuntu 16.04),我的脚本显然不再工作了。这是我在 Linux 机器上遇到的错误:

Traceback (most recent call last):
File "roblox.py", line 2, in <module>
from utils import *
File "/home/py/newbot/utils.py", line 18
key, *values = line.split(" ")
^
SyntaxError: invalid syntax

它引用的脚本中的行是这样的

def string_to_dict(headers):
headers_dict = {}
for line in headers.split("\n"):
if not line: continue
line = line.strip()
key, *values = line.split(" ")
key = key[:-1]
if not (key and values): continue
headers_dict[key] = " ".join(values)
return headers_dict

有什么可能出错的想法吗?

最佳答案

此语法在 python 2 中无效。使用 python3 运行您的脚本。

关于python - python 的新手问题,脚本在其他操作系统上工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42234580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com