python 新手之 文件import问题
2011-03-02 21:32
429 查看
初学python不知如何引入py文件
我写的爬虫函数。catchInfo.py
但是当我在console上运行python时,找不到文件里面的函数和变量
according c++ coding experience,i find maybe use catchInfo reference
我写的爬虫函数。catchInfo.py
# coding=gb2312 from lxml import * import lxml.html import urllib2 import lxml.html as H import sys reload(sys) sys.setdefaultencoding('utf-8') def catchInfoByUXpath(url,xstr): c=urllib2.urlopen(url) f=c.read() doc=H.document_fromstring(f) result=doc.xpath(xstr) return result url="http://www.baidu.cn" xstr='/html/body/div/p[2]/a'
但是当我在console上运行python时,找不到文件里面的函数和变量
dir(catchInfo) import catchInfo url #报错 Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'url' is not defined
according c++ coding experience,i find maybe use catchInfo reference
>>> catchInfo.url 'http://www.baidu.cn' >>>
相关文章推荐
- python项目中不同文件夹py源文件之间如何相互调用--Python import中相对路径的问题
- 【python】python新手必碰到的问题---encode与decode,中文乱码[转]
- python zip 文件解压中文乱码问题解决
- python读取文件问题
- HTTP 文件下载上传之系列问题-python
- 解决python3.6下scrapy中xpath.extract()匹配出来的内容转成json与.csv文件没有编码(unicode)的问题
- python新手必碰到的问题---encode与decode,中文乱码
- python导入csv文件出现SyntaxError问题分析
- python读取文件写入数据库中编码问题
- Python 文件命名陷阱:importError import socket
- Python模块函数:os.listdir 打印Win7目录中的文件-中文乱码问题
- 解析thinkphp import 文件内容变量失效的问题
- Python处理MLDonkey 下载中文文件乱码问题 (2)
- python使用import导入文件夹中的文件
- 快速更新 被import 的 python格式的数据问题, 部分 数据更新没被认出来
- 简单解决Python文件中文编码问题
- Python文件编码问题(SyntaxError: Non-ASCII character '\xef' in file)
- Python写UTF8文件,UE、记事本打开依然乱码的问题
- 看python的91个建议第7个建议, 常量写到同一个文件引发的一个问题
- python csv windows下写文件有空行问题