Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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 非类型对象没有属性';文本';仅来自linux_Python_Python 3.x - Fatal编程技术网

Python 非类型对象没有属性';文本';仅来自linux

Python 非类型对象没有属性';文本';仅来自linux,python,python-3.x,Python,Python 3.x,我正在使用debian的phyton 3.6.9,我的代码有问题 我的代码做什么? 我的代码从xml url(使用bs4和urllib)提取新闻,并使用telepot库将其发布在电报频道上。检查在出版之日进行 我有什么问题? 我的代码在windows上运行得非常好。在Linux上,它正确地执行了抓取操作,但当我到达网站上的最后一条新闻时,它返回了以下错误: Traceback (most recent call last): File "bot.py", line 32,

我正在使用debian的phyton 3.6.9,我的代码有问题

我的代码做什么? 我的代码从xml url(使用bs4和urllib)提取新闻,并使用telepot库将其发布在电报频道上。检查在出版之日进行

我有什么问题? 我的代码在windows上运行得非常好。在Linux上,它正确地执行了抓取操作,但当我到达网站上的最后一条新闻时,它返回了以下错误:

Traceback (most recent call last):
  File "bot.py", line 32, in <module>
    get_data()
  File "bot.py", line 27, in get_data
    prev_date_time = datetime.datetime.strptime(news_list[0].pubDate.text, '%a, %d %b %Y %H:%M:%S %z')
AttributeError: 'NoneType' object has no attribute 'text'

这里的元素是
pubdate
而不是
pubdate
,python区分大小写,因此您需要使用确切的名称:

prev_date_time = datetime.datetime.strptime(news_list[0].pubdate.text, '%a, %d %b %Y %H:%M:%S %z')
prev_date_time = datetime.datetime.strptime(news_list[0].pubdate.text, '%a, %d %b %Y %H:%M:%S %z')