我正在使用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