我如何使用python3从控制台输入文本?

时间:2017-04-17 10:25:30

标签: python python-3.x

我正在尝试从标准输入中获取输入并将其存储在变量中。我写的代码是这样的:

titles = input("Please enter Wikipedia article to process: \n")

在运行程序时等待输入,当我从wikipedia复制文本并尝试粘贴它时,它开始给出错误。我不知道我需要做什么才能让我的程序输入维基百科的段落,并在打印时删除参考号。

这是我得到的:

>>> titles = input("Please enter Wikipedia article to process: \n")
Please enter Wikipedia article to process:
Villa Park is a football stadium in Aston, Birmingham, England, with a seating capacity of 42,682. It has been the home of Aston Villa Football Club since 1897. The ground is less than a mile from both Witton and Aston railway stations and has hosted sixteen England internationals at senior level, the first in 1899 and the most recent in 2005. Villa Park has hosted 55 FA Cup semi-finals, more than any other stadium.
>>>
>>> In 1897, Aston Villa moved into the Aston Lower Grounds, a sports ground in a Victorian amusement park in the former grounds of Aston Hall, a Jacobean stately home. The stadium has gone through various stages of renovation and development, resulting in the current stand configuration of the Holte End, Trinity Road Stand, North Stand and the Doug Ellis Stand. The club has initial planning permission to redevelop the North Stand, which will increase the capacity of Villa Park from 42,682 to about 50,000.
  File "<stdin>", line 1
    In 1897, Aston Villa moved into the Aston Lower Grounds, a sports ground in a Victorian amusement park in the former grounds of Aston Hall, a Jacobean stately home. The stadium has gone through various stages of renovation and development, resulting in the current stand configuration of the Holte End, Trinity Road Stand, North Stand and the Doug Ellis Stand. The club has initial planning permission to redevelop the North Stand, which will increase the capacity of Villa Park from 42,682 to about 50,000.
          ^
SyntaxError: invalid syntax
>>>
>>> Before 1914, a cycling track ran around the perimeter of the pitch where regular cycling meetings were hosted as well as athletic events. Aside from football-related uses, the stadium has seen various concerts staged along with other sporting events including boxing matches and international rugby league and rugby union matches. In 1999, the last ever final of the UEFA Cup Winners' Cup took place at Villa Park. Villa Park also hosted the 2012 FA Community Shield, as Wembley Stadium was in use for the final of the Olympic football tournament.[3]
  File "<stdin>", line 1
    Before 1914, a cycling track ran around the perimeter of the pitch where regular cycling meetings were hosted as well as athletic events. Aside from football-related uses, the stadium has seen various concerts staged along with other sporting events including boxing matches and international rugby league and rugby union matches. In 1999, the last ever final of the UEFA Cup Winners' Cup took place at Villa Park. Villa Park also hosted the 2012 FA Community Shield, as Wembley Stadium was in use for the final of the Olympic football tournament.[3]
              ^
SyntaxError: invalid syntax

请帮助我。 请注意我使用的是python 3.6

0 个答案:

没有答案