【发布时间】:2010-11-30 07:35:03
【问题描述】:
class gpagelet:
"""
Holds 1) the pagelet xpath, which is a string
2) the list of pagelet shingles, list
"""
def __init__(self, parent):
if not isinstance( parent, gwebpage):
raise Exception("Parent must be an instance of gwebpage")
self.parent = parent # This must be a gwebpage instance
self.xpath = None # String
self.visibleShingles = [] # list of tuples
self.invisibleShingles = [] # list of tuples
self.urls = [] # list of string
class gwebpage:
"""
Holds all the datastructure after the results have been parsed
holds: 1) lists of gpagelets
2) loc, string, location of the file that represents it
"""
def __init__(self, url):
self.url = url # Str
self.netloc = False # Str
self.gpagelets = [] # gpagelets instance
self.page_key = "" # str
有没有办法让我的类 json 可序列化?我担心的是递归引用。
【问题讨论】:
-
这个答案可能会有所帮助:stackoverflow.com/a/28253689/303114
-
你的问题标题很模糊。你应该改进它。
-
同一个问题,但有一个封闭的答案:stackoverflow.com/a/7409526/2728644
标签: python json serializable