Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从编号为0到100的项目列表中创建编号>=60的新项目列表_Python_Web Scraping_Html Lists_Custom Lists - Fatal编程技术网

Python 从编号为0到100的项目列表中创建编号>=60的新项目列表

Python 从编号为0到100的项目列表中创建编号>=60的新项目列表,python,web-scraping,html-lists,custom-lists,Python,Web Scraping,Html Lists,Custom Lists,列表中的项目是旁边评级为0到100的电影标题。这是它的一部分 [(u'The Girl on the Train', 43), (u'Keeping Up With The Joneses', 19), (u'Ouija: Origin of Evil', 82), (u'Long Way North (Tout en haut du monde)', 98), (u'The Whole Truth', 29), (u'Come And Find Me', 67), (u'LEGO Jurass

列表中的项目是旁边评级为0到100的电影标题。这是它的一部分

[(u'The Girl on the Train', 43),
(u'Keeping Up With The Joneses', 19),
(u'Ouija: Origin of Evil', 82),
(u'Long Way North (Tout en haut du monde)', 98),
(u'The Whole Truth', 29),
(u'Come And Find Me', 67),
(u'LEGO Jurassic World: The Indominus Escape', None),
(u'My Father, Die', 78)...]
我想列一张得分在60分或60分以上的电影名单。这是我尝试过的一个不起作用的东西,这段代码将从Rottentomatoos网站上提取一点数据,仅供参考

import requests

r = requests.get('https://www.rottentomatoes.com/api/private/v2.0/browse?page=1&limit=30&type=dvd-top-rentals&services=amazon%3Bamazon_prime%3Bfandango_now%3Bhbo_go%3Bitunes%3Bn    etflix_iw%3Bvudu&sortBy=popularity')


list = []
data = r.json()
for result in data["results"]:
    list.append((result["title"], result["tomatoScore"]))

list2 = [i for i in list if i >=60]

print list2
我还想有一个分数在60分或以上的所有电影标题被截断为电影标题的文本,这样我就可以有一个程序,将它们输入到网站的搜索字段。所以,如果你知道这是怎么做到的,那会让我在黑暗中少一些额外的感觉。如果问怎么做是要求太多,也许只是一个提示。 谢谢大家!

变化

list2 = [i for i in list if i >= 60] 

不要给你的名单打电话。它将覆盖python列表。

好问题:

或许,这将有助于您:

for i, j in list:
    if j >= 60:
        print j
这只打印大于60的值。如果要将其附加到列表中,请使用:

for i, j in list:
    if j >= 60:
        list2.append(j)

希望能成功

@Ant在提问之前请先阅读。请注意,我认为您指的是print I和list2.appendi,因为我们使用的是python,而不是任何古老的语言cobol、fortran?所需的单字符变量,我建议用于标题、列表中的排名。。。除了使用Yevhen的答案更具Python风格的列表理解之外,我还使用Python。我确实喜欢叶文的回答。我无法让另一个工作。是按照耶文的建议把我的列表变成一个元组,还是从元组开始?如何将其更改回列表?
for i, j in list:
    if j >= 60:
        list2.append(j)