Problemas com o python 3.3 no Ubuntu 13.04

0

Estou constantemente obtendo EOF ao ler erros de linha ao executar:

List0 = []
inputtedStr = input()
while inputtedStr != "#####":
    List0.append(inputtedStr)
    inputtedStr = input()
print()
print("Original List: ", List0)
List1 = []
for i in range(0, len(List0)):
    if str.strip(List0[i]) != str.strip(List0[i-1]):
        List1.append(str.strip(List0[i]))
    else:
        continue
print()
print("NO Duplicates: ", List1)

Isso acontece quando eu o executo em um terminal do Windows, qualquer sugestão sobre o que eu posso estar fazendo errado será muito apreciada! Além disso, esta não é a primeira vez que eu recebi este erro apenas quando rodando na máquina Ubuntu?

    
por p_mike_v 02.05.2013 / 06:48

1 resposta

0

Você precisa executar o script com python3

~$ python Test.py 
thefourtheye
#####
Traceback (most recent call last):
  File "Test.py", line 5, in <module>
    inputtedStr = input()
  File "<string>", line 1
    #####
        ^
SyntaxError: unexpected EOF while parsing

~$ python --version
Python 2.7.4

~$ python3 --version
Python 3.3.1 

~$ python3 Test.py 
WELCOME
thefourtheye
###
####
#####

Original List:  ['WELCOME', 'thefourtheye', '###', '####']

NO Duplicates:  ['WELCOME', 'thefourtheye', '###', '####']

ou

Como sugerido por @MiJyn nos comentários,

  1. apenas edite seu arquivo e inclua a seguinte linha como a primeira linha

    #!/usr/bin/env python3  
    
  2. chmod 755 <filename>.py

  3. ./<filename>.py

por thefourtheye 20.06.2013 / 06:02