我正在尝试将networkx与Python一起使用.当我运行此程序时,它会收到此错误.有什么遗漏?
#!/usr/bin/env python
import networkx as nx
import matplotlib
import matplotlib.pyplot
import matplotlib.pyplot as plt
G=nx.Graph()
G.add_node(1)
G.add_nodes_from([2,3,4,5,6,7,8,9,10])
#nx.draw_graphviz(G)
#nx_write_dot(G, 'node.png')
nx.draw(G)
plt.savefig("/var/www/node.png")
Traceback (most recent call last):
File "graph.py", line 13, in <module>
nx.draw(G)
File "/usr/lib/pymodules/python2.5/networkx/drawing/nx_pylab.py", line 124, in draw
cf=pylab.gcf()
File "/usr/lib/pymodules/python2.5/matplotlib/pyplot.py", line 276, in gcf
return figure()
File "/usr/lib/pymodules/python2.5/matplotlib/pyplot.py", line 254, in figure
**kwargs)
File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_tkagg.py", line 90, in new_figure_manager
window = Tk.Tk()
File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1650, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用c ++从stdin读取,使用此代码
#include <iostream>
using namespace std;
int main() {
while(cin) {
getline(cin, input_line);
cout << input_line << endl;
};
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我编译时,我收到此错误..
[root@proxy-001 krisdigitx]# g++ -o capture -O3 capture.cpp
capture.cpp: In function âint main()â:
capture.cpp:6: error: âinput_lineâ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
任何想法丢失了吗?
我是django的新手,我想制作一个简单的表格,根据我可以使用django的表格模块制作表格的文档
from django import forms
class CronForm(forms.Form):
name = forms.CharField(max_length=100)
email = forms.EmailField(required=False, label='Your e-mail address')
message = forms.CharField(widget=forms.Textarea)
def clean_message(self):
message = self.cleaned_data['message']
num_words = len(message.split())
if num_words < 4:
raise forms.ValidationError("Not enough words!")
return message
Run Code Online (Sandbox Code Playgroud)
我想知道的是如何创建一个月的下拉列表,即从1到31?
有些人在他们的表单模板中使用javascript完成它,可以在django中完成吗?
我从数据库函数返回一个字符串或NULL到主程序,有时我从异常中得到这个错误:
basic_string::_S_construct NULL not valid
Run Code Online (Sandbox Code Playgroud)
我认为它是因为从数据库函数返回NULL值?有任何想法吗???
string database(string& ip, string& agent){
//this is just for explanation
.....
....
return NULL or return string
}
int main(){
string ip,host,proto,method,agent,request,newdec;
httplog.open("/var/log/redirect/httplog.log", ios::app);
try{
ip = getenv("IP");
host = getenv("CLIENT[host]");
proto = getenv("HTTP_PROTO");
method = getenv("HTTP_METHOD");
agent = getenv("CLIENT[user-agent]");
if (std::string::npos != host.find(string("dmnfmsdn.com")))
return 0;
if (std::string::npos != host.find(string("sdsdsds.com")))
return 0;
if (method=="POST")
return 0;
newdec = database(ip,agent);
if (newdec.empty())
return 0;
else {
httplog << "Redirecting to splash page for user IP: …Run Code Online (Sandbox Code Playgroud) 我有一个包含以下格式数据的文件:
1351649601.045 421 2945
1351649601.684 1036 28591
1351649603.310 128 1620
1351649603.413 93 0
1351649603.375 132 1762
1351649603.318 218 1761
1351649603.434 412 176
1351649603.441 520 5780
1351649603.480 565 11070
1351649603.556 644 11535
gnuplot> set term png
Terminal type set to 'png'
gnuplot> set output "output.png"
gnuplot> plot "data.txt" using 1:2 with lines
Run Code Online (Sandbox Code Playgroud)
但是,gnuplot无法正确读取日期.你有什么想法?
解决了:
set term png xffffff
set output "output.png"
set size 17,17
set title "HTTP payload size and response time"
set style data fsteps
set xlabel "Date"
set timefmt …Run Code Online (Sandbox Code Playgroud) 我使用ftplib连接到ftp站点.我想获取最近上传的文件并下载它.我能够连接到ftp服务器并列出文件,我也将它们放在一个列表中并获得datefield转换.是否有任何功能/模块可以获取最近的日期并从列表中输出整行?
#!/usr/bin/env python
import ftplib
import os
import socket
import sys
HOST = 'test'
def main():
try:
f = ftplib.FTP(HOST)
except (socket.error, socket.gaierror), e:
print 'cannot reach to %s' % HOST
return
print "Connect to ftp server"
try:
f.login('anonymous','al@ge.com')
except ftplib.error_perm:
print 'cannot login anonymously'
f.quit()
return
print "logged on to the ftp server"
data = []
f.dir(data.append)
for line in data:
datestr = ' '.join(line.split()[0:2])
orig-date = time.strptime(datestr, '%d-%m-%y %H:%M%p')
f.quit()
return
if __name__ == '__main__':
main() …Run Code Online (Sandbox Code Playgroud) 我试图使用python pyes模块将具有6M记录的csv文件索引到elasticsearch,代码逐行读取记录并将其推送到elasticsearch ...任何想法如何将其作为批量发送?
import csv
from pyes import *
import sys
header = ['col1','col2','col3','col3', 'col4', 'col5', 'col6']
conn = ES('xx.xx.xx.xx:9200')
counter = 0
for row in reader:
#print len(row)
if counter >= 0:
if counter == 0:
pass
else:
colnum = 0
data = {}
for j in row:
data[header[colnum]] = str(j)
colnum += 1
print data
print counter
conn.index(data,'accidents-index',"accidents-type",counter)
else:
break
counter += 1
Run Code Online (Sandbox Code Playgroud) 我正在使用下面的maven配置构建一个war应用程序文件,但是当我在tomcat中启动应用程序时,Context Root被设置为"/CommerceApi-0.0.1-SNAPSHOT/"
我希望将其设置为"/ api",
任何想法?,下面是pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CommerceApi</groupId>
<artifactId>CommerceApi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>CommerceApiCommon</groupId>
<artifactId>CommerceApiCommon</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud) 我一直在尝试了解系统调用,并想了解 set_tid_address 的工作原理。从我读到的基本上来说,它返回所执行的程序或进程的pid。
我已经用 ls 对此进行了测试,但是对于某些命令(例如 uptime、top 等),我没有看到使用 set_tid_address 。这是为什么?
我正在实施双向SSL身份验证,然后通过Kerberos进行额外身份验证,然后通过反向代理将用户重定向到内部服务器.
即:
SSL auth <--> Apache Server + kerberos auth using login/password <--reverse proxy-->> internal server
Run Code Online (Sandbox Code Playgroud)
此设置目前有效:
现在我的想法是使用这个配置,因为我可以通过Tornado控制用户的行为
SSL auth <--> Apache server <---> Tornado webserver for kerberos auth <---> reverse proxy <---> internal server
Run Code Online (Sandbox Code Playgroud)
我已经获得了SSL身份验证和Kerberos身份验证.
但是,如何告诉Tornado反向proxy(apache)内部服务器?