我正在运行apache2服务器.CGIHTTPServer在目录/ mnt/hgfs/wind/BTech_BTP/BTP/code/final_code /中运行.我正在使用网址http:// localhost:8000/test/www/adder.html.
我在../final_code/test/www目录中有三个文件.
adder.html包含:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Adder</title>
</head>
<body>
<h1>Fantastic Adder - Sum Two Numbers<br></h1>
<br>
<form action="adder.cgi" method="get" enctype="multipart/form-data">Number
1:<input maxlength="60" size="60" value="0" name="x"> <br>
<br>
Number 2:<input name="y" value="0" maxlength="60" size="60"><br>
<br>
<input value="Find Sum" type="submit">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
adder.cgi包含
#!/usr/bin/env python3
import cgi # NEW
def main(): # NEW except for the call to processInput
form = cgi.FieldStorage() # standard cgi script lines …
Run Code Online (Sandbox Code Playgroud) 我正在尝试打印图形的连接组件.但它印刷的是发电机的对象.
这是我的graph.py
import networkx as nx
import matplotlib.pyplot as plt
#import math
import csv
#import random as rand
import sys
def buildG(G, file_, delimiter_):
#construct the weighted version of the contact graph from cgraph.dat file
reader = csv.reader(open(file_), delimiter=delimiter_)
for line in reader:
if float(line[2]) != 0.0:
G.add_edge(int(line[0]),int(line[1]),weight=float(line[2]))
def main():
graph_fn="tempset3.txt";
G = nx.Graph() #let's create the graph first
buildG(G, graph_fn, ',')
print G.nodes()
print G.number_of_nodes()
#nx.draw(G)
#plt.show(G)
n = G.number_of_nodes()
print ("no of nodes: ", n)
comps=nx.connected_components(G)
print comps …
Run Code Online (Sandbox Code Playgroud)