【发布时间】:2016-04-17 16:05:04
【问题描述】:
我正在使用 OMDB API 编写电影情节。我想将绘图值限制在输出中的 80 长度内。我已经搜索过,但找不到任何东西。 jsonvalues['Plot'] 可以包含超过 80 个字符。我想在多行中打印它的值。
import urllib
import json
name = raw_input('Enter the movie name >')
url = "http://www.omdbapi.com/?t="+name+"&r="+"json"
response = urllib.urlopen(url).read()
jsonvalues = json.loads(response)
if jsonvalues["Response"]=="True":
print jsonvalues["imdbRating"]
print 'The plot of the movie is: '+jsonvalues['Plot']
else:
print "The movie name was not found"
【问题讨论】:
-
发布了答案。检查它是否是你想要的。