【问题标题】:Getting different movie info from script than from python shell从脚本获取不同的电影信息而不是从 python shell
【发布时间】:2018-01-28 11:38:00
【问题描述】:

我有以下脚本可以将电影的演员表输出到文本文档:

import imdb

ia = imdb.IMDb()
movie = ia.get_movie(0111161)
cast = movie['cast']
text_file = open("Cast.txt", "w")
text_file.write("{0}".format(movie))
text_file.write("{0}".format(cast))
text_file.close()

如您所见,我从 IMDB 网站而不是从数据库中抓取它。 当我在 python shell (2.7.13) 中执行这个脚本时,我得到了“肖申克的救赎”的演员表,但是当我从命令行 (python myscript.py) 执行它时,我得到了电影 '29 Acacia 的演员表大道',id=0037489。 怎么会这样?

【问题讨论】:

    标签: python shell imdb imdbpy


    【解决方案1】:

    你应该使用

    movie = ia.get_movie("0111161")

    而不是

    movie = ia.get_movie(0111161)

    【讨论】:

      【解决方案2】:

      0111161 以 0 开头,因此 Python 将其解释为 八进制 数字。它的十进制值为 37489。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-08-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-26
        • 2019-03-25
        相关资源
        最近更新 更多