将变量信息从一个python文件传输到另一个python文件

时间:2015-07-27 22:30:06

标签: python io

尝试将加载到变量中的数据从python程序发送到另一个变量。相关代码如下。

正在创建文件数据:

import requests
from privateDiningParser import isPrivateD

from pydal import DAL, Field
from lxml import etree


r = requests.get(urlCheck)

if r.status_code == 404:
     print ('No private dining information')

else:
     print('Parsing private dining information')
     isPrivateD(urlCheck)

文件数据将:

import requests
from lxml import etree

url = ''

def isPrivateD(privateUrl):

    url = privateUrl

parser = etree.HTMLParser()

tree = etree.parse(url,parser)
root = tree.getroot()

预期结果是:

print('You made it' + privateUrl) #Testing to see if files connected

这是我得到的错误:

    tree = etree.parse(url,parser)
  File "lxml.etree.pyx", line 3239, in lxml.etree.parse (src/lxml/lxml.etree.c:69955)
  File "parser.pxi", line 1748, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:102066)
  File "parser.pxi", line 1774, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:102330)
  File "parser.pxi", line 1678, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:101365)
  File "parser.pxi", line 1110, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:96817)
  File "parser.pxi", line 582, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:91275)
  File "parser.pxi", line 683, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:92461)
  File "parser.pxi", line 620, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:91722)
IOError: Error reading file '': failed to load external entity ""

谢谢大家,如果问题很简单,我很抱歉,2个小时之后就各种文档而言仍然无法弄清楚我做错了什么

1 个答案:

答案 0 :(得分:0)

让它发挥作用,

问题出在我发送信息的文件中。只有第二个文件中的一些代码在一个方法中,其余的作为一个脚本,我不能有一个或另一个。固定和工作。拥抱和亲吻