如何请求用户输入并将该输入用于我创建的文本摘要生成器?

2024-04-19 19:10:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我根据在Github上找到的代码创建了一个文本摘要生成器。我试着要写剧本,要课文的标题,要实际的课文。你知道吗

title =    """ """

content = """
As metro Atlanta's weather and road conditions continue to thaw after this week's snowstorm, MARTA is planning modified bus and Mobility (paratransit) service starting tomorrow, initially on 30 "life-line" routes. MARTA's rail service will continue operating on a weekend schedule on all lines.

Bus and Mobility service will start at 7 a.m. Friday and run until 11:30 p.m. (See below for preliminary list of restored bus routes or visit MARTA's website: itsmarta.com.) The first round of bus routes being restored provide transit access to some of the region's major hospitals, job centers and commercial corridors. Customers may experience extended waits on some routes are asked to please allow extra time to complete their trips. Based on specific road and traffic conditions, more routes may be added throughout the day and real-time adjustments to the bus schedule are possible.

MARTA rail service will begin for customers at 4:35 a.m. Friday and run until about 2 a.m. on Saturday. Customers should mostly expect wait times for trains ranging from 10 to 20 minutes – conditions permitting. Since some rail stations are open to the elements, customers are advised to dress accordingly.

"""

^这就是我在代码中的内容:在标题所在的位置,输入标题。内容是用户希望摘要的文本。你知道吗

如果您想要一个演示:您可以转到http://runnable.com/Uv1foJAZ0BxuAABl/summerizer-for-python并单击run。你知道吗

我怎样才能让节目要求标题和内容?你知道吗


Tags: andthetorun标题foronservice
2条回答

在Python2.x中,可以执行以下操作:

usertext = raw_input("message here")

对于python 3.x:

usertext = input("message here")

你是否在寻求一种方法来获取用户对标题和内容的输入?你知道吗

http://docs.python.org/2/library/functions.html#raw_input

title = raw_input("Please input your title here: ")
content = raw_input("Please enter your content here: ")

编辑:Python: user input and commandline arguments的副本,或多或少

相关问题 更多 >