gpt4 book ai didi

python - 从脚本获取与从 python shell 获取不同的电影信息

转载 作者:太空宇宙 更新时间:2023-11-04 07:31:51 25 4
gpt4 key购买 nike

我有以下脚本可以将电影类型转换输出到文本文档:

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。怎么会这样?

最佳答案

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

关于python - 从脚本获取与从 python shell 获取不同的电影信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45779426/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com