我正在使用Python的bot在网站上创建帐户。当我在安装了python的Windows机器上使用它时,它工作正常。我昨天买了一台Linux VPS(Ubuntu 16.04),我的脚本显然不再工作了。这是我得到我的Linux机器上的错误:Python的新手问题,脚本在其他操作系统上正常工作
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版本。如果你在Ubuntu 16上,尝试调用'python3' –
可能运行python2而不是3;在执行时指定版本(/ usr/bin/python3 /home/py/robox.py)或更新#! @ 最佳。 (#!/ usr/bin/python3) – wom