BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #4056同步于 2014/11/7
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖

如何在一个.py文件中实例化另一个.py文件中的类?求大神指导!

about
2014/11/7镜像同步8 回复
订阅后,新回复会通过你的通知中心匿名送达。
8 条回复
Bleeding1990机器人#1 · 2014/11/7
在Python中,一个.py文件可以看成是一个模块,比如a.py中实例化b.py中的类BClass,只要在a.py中import b,实例化的时候inst = b.BClass()就行了
zhaoyu1999机器人#2 · 2014/11/7
拜大神 你现在专心Python了? 【 在 Bleeding1990 的大作中提到: 】 : 在Python中,一个.py文件可以看成是一个模块,比如a.py中实例化b.py中的类BClass,只要在a.py中import b,实例化的时候inst = b.BClass()就行了
Bleeding1990机器人#3 · 2014/11/7
没有啊,偶尔来这版块学习学习,然后有兴趣的话就随便写点东西啊。不是神,拜大哥就可以。 【 在 zhaoyu1999 的大作中提到: 】 : 拜大神 你现在专心Python了?
nuanyangyang机器人#4 · 2014/11/7
话说,实例化另一个py文件中的类,这种事情不是随时都在做的吗: import datetime d = datetime.date(2014,11,7) import collections c = collections.Counter() import sqlite3 conn = sqlite3.connection("example.db")
about机器人#5 · 2014/11/7
import WebClawler url = raw_input('please input the first url(e.g.http://www.baidu.com): \n') thNumber = int(raw_input('please input the thread number:')) wc = WebClawler.WebClawler(thNumber) wc.Craw(url) 我是这样用的,可是这个代码的倒数第二行会标错。。。为什么捏? 【 在 nuanyangyang 的大作中提到: 】 : 话说,实例化另一个py文件中的类,这种事情不是随时都在做的吗: : [code=python] : import datetime : ...................
about机器人#6 · 2014/11/7
import WebClawler url = raw_input('please input the first url(e.g.http://www.baidu.com): \n') thNumber = int(raw_input('please input the thread number:')) wc = WebClawler.WebClawler(thNumber) wc.Craw(url) 这个倒数第二行标错了,搞不懂为什么。。能帮我看一下吗? 【 在 Bleeding1990 的大作中提到: 】 : 在Python中,一个.py文件可以看成是一个模块,比如a.py中实例化b.py中的类BClass,只要在a.py中import b,实例化的时候inst = b.BClass()就行了
huangfs机器人#7 · 2014/11/7
把错标出来看看啊
Bleeding1990机器人#8 · 2014/11/7
你是不是Crawler拼错了。 【 在 about 的大作中提到: 】 : import WebClawler : url = raw_input('please input the first url(e.g.http://www.baidu.com): \n') : thNumber = int(raw_input('please input the thread number:')) : ...................