我正在使用带有Sublime文本3的Anaconda.我将lint设置保留为默认值,但以下覆盖除外,我已将其包含在.sublime-project文件中.
"settings": {
"anaconda_gutter_marks": true,
"anaconda_gutter_theme": "alpha",
"anaconda_linting_behaviour": "always",
}
Run Code Online (Sandbox Code Playgroud)
我希望能够忽略某些行的"行太长",特别是注释中包含url的行.我喜欢将它用于其他线路,所以我宁愿不要完全禁用它.
我只找到了关于为pylint执行此操作的信息,但是如果可能的话,我宁愿使用默认的linter,因为这似乎在这个插件中有自己的问题.
我已经包含了sublimelinter标签,因为anaconda表示它的linting是基于该插件的.
我有一个嵌入式jetty服务器的应用程序,我就是这样开始的(放在main()中并使用eclipse启动):
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setResourceBase("web/");
context.setDescriptor("web/WEB-INF/web.xml");
context.setConfigurations(new Configuration[]{
new AnnotationConfiguration(), new WebXmlConfiguration(),
new WebInfConfiguration(), new TagLibConfiguration(),
new PlusConfiguration(), new MetaInfConfiguration(),
new FragmentConfiguration(), new EnvConfiguration()});
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.join();
Run Code Online (Sandbox Code Playgroud)
我的web.xml看起来像这样(现在是空的,我不确定我是否可以完全删除它):
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="false"
version="3.0">
</web-app>
Run Code Online (Sandbox Code Playgroud)
我有一个简单的类设置如下:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns={"/test"})
public class TestServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.getRequestDispatcher("/WEB-INF/html/index.html").forward(request,response);
}
}
Run Code Online (Sandbox Code Playgroud)
当我在web.xml中使用传统的servlet映射时,我的应用程序工作正常.但是当我删除web.xml映射并使用注释时,我只能获得404.看起来它根本不是在扫描注释.控制台看起来像这样:
2012-08-01 …
Run Code Online (Sandbox Code Playgroud) 我编写了一个简单的函数,它接收实现 .index() 的内容和要检查的字符列表。
我的假设是,由于字符串和元组都是不可变的,因此它们将具有相似的性能(或者至少,元组会优于列表)。相反,元组似乎等同于列表。这是为什么?
from string import ascii_lowercase
from random import randint
from timeit import Timer
def check_index(st, guesses):
for i in guesses:
st.index(i)
if __name__ == "__main__":
num_checks = 10
lst = [n for n in ascii_lowercase]
st = ascii_lowercase
tup = tuple(lst)
guesses = [ascii_lowercase[randint(0, len(ascii_lowercase)-1)]
for n in xrange(num_checks)]
def run_string():
check_index(st, guesses)
def run_list():
check_index(lst, guesses)
def run_tuple():
check_index(tup, guesses)
t2 = Timer(run_list)
print "List", t2.timeit()
t3 = Timer(run_tuple)
print "Tuple", t3.timeit()
t = Timer(run_string)
print …
Run Code Online (Sandbox Code Playgroud) 如何使用Python更改域用户的密码?我板上有ldap模块,但没有解决方案。我设法通过ldap查询当前设置,但是如何修改呢?
import ldap
import sys
host = 'ldap://10.172.0.79'
con = ldap.initialize(host)
BIND_DN = "administrator@biztalk.com"
BIND_PASS = "a-123456"
con.set_option( ldap.OPT_X_TLS_DEMAND, True )
con.set_option( ldap.OPT_DEBUG_LEVEL, 255 )
PASSWORD_ATTR = "unicodePwd"
username="bizadmin"
user_dn = "CN=%s,OU=User,OU=biztalk,DC=biz-talk,DC=com" % username
password = 'New12345'
# Set AD password
unicode_pass = unicode("\"" + password + "\"", "iso-8859-1")
password_value = unicode_pass.encode("utf-16-le")
add_pass = [(ldap.MOD_REPLACE, PASSWORD_ATTR, [password_value])]
# Replace password
try:
con.modify_s(user_dn, add_pass)
print "Active Directory password for", username, "was set successfully!"
except ldap.LDAPError, e:
sys.stderr.write('Error setting AD password for: …
Run Code Online (Sandbox Code Playgroud)