这是我的fiddle
我正在寻找从html中的inpt形式获取值。例如,我想获得在class FileSystem():
def __init__(self,filePath=None):
self.children = []
if filePath != None:
try:
self.name, child = filePath.split("/", 1)
self.children.append(FileSystem(child))
except (ValueError):
self.name = filePath
def addChild(self, filePath):
try:
thisLevel, nextLevel = filePath.split("/", 1)
try:
if thisLevel == self.name:
thisLevel, nextLevel = nextLevel.split("/", 1)
except (ValueError):
self.children.append(FileSystem(nextLevel))
return
for child in self.children:
if thisLevel == child.name:
child.addChild(nextLevel)
return
self.children.append(FileSystem(nextLevel))
except (ValueError):
self.children.append(FileSystem(filePath))
def getChildren(self):
return self.children
def printAllChildren(self, depth = -1):
depth += 1
print "\t"*depth + "Name: "+ self.name
if len(self.children) > 0:
print "\t"*depth +"{ Children:"
for child in self.children:
child.printAllChildren(depth)
print "\t"*depth + "}"
def makeDict(self):
if len(self.children) > 0:
dictionary = {self.name:[]}
for child in self.children:
dictionary[self.name].append(child.makeDict())
return dictionary
else:
return self.name
records = ["base/images/graphs/one.png", "base/images/tikz/two.png",
"base/refs/images/three.png", "base/one.txt", "base/chapters/two.txt"]
myFiles = FileSystem(records[0])
for record in records[1:]:
myFiles.addChild(record)
print myFiles.makeDict()
输入表单中输入的值。
Cat name:
我正在思考类似下面的事情:
<div id="admin-form">
<form>
Cat name:<input id="admin-cat-name" type="text" name="cat-name" placeholder="10" value="10"><br>
Source: <input id="admin-source" type="text" name="source"><br>
Count: <input id="admin-count" type="text" name="count">
<button id="save-button" type="button">Save</button>
<button id="cancel-button" type="button">Cancel</button>
</form>
</div>
但我无法从输入表单中获得值。任何人都可以建议我这样做吗?如果我以正确的方式解决这个问题?