我可以在python中计算exp(1 + 2j)吗?
exp(1+2j)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert complex to float
Run Code Online (Sandbox Code Playgroud) <form id="search" action="/search" method="get" autocomplete="off">
<div>
<input type = "button" name = 'test_button" value = "test" />
</div>
</form>
<script>
document.getElementById("test_button").value = "changed_test"
</script>
Run Code Online (Sandbox Code Playgroud)
正如上面的HTML代码所示,我已经定义了一个带有名称test_button和值的按钮,并test使用脚本标记中的代码更改了它的值.
现在我正在调试一个大型网页,它在Linux中使用Firebug和Firefox这样的机制.
我想知道如何找到更改其value属性的脚本<input ... />,但是网页太大,<script>自动执行的各种 匿名函数几乎不可能script手动找到特定的.
由于我在Linux,我不能使用任何Microsoft工具来搜索整个网页.我只有Firebug和Chrome.Firebug能意识到吗?有没有人有一个好主意如何找到<script>改变的具体value?
现在我正在研究如何尽快从网站上获取数据.为了获得更快的速度,我考虑使用多线程.这是我用来测试多线程和简单帖子之间差异的代码.
import threading
import time
import urllib
import urllib2
class Post:
def __init__(self, website, data, mode):
self.website = website
self.data = data
#mode is either "Simple"(Simple POST) or "Multiple"(Multi-thread POST)
self.mode = mode
def post(self):
#post data
req = urllib2.Request(self.website)
open_url = urllib2.urlopen(req, self.data)
if self.mode == "Multiple":
time.sleep(0.001)
#read HTMLData
HTMLData = open_url.read()
print "OK"
if __name__ == "__main__":
current_post = Post("http://forum.xda-developers.com/login.php", "vb_login_username=test&vb_login_password&securitytoken=guest&do=login", \
"Simple")
#save the time before post data
origin_time = time.time()
if(current_post.mode == "Multiple"):
#multithreading POST …Run Code Online (Sandbox Code Playgroud) 我有一台高分辨率的笔记本电脑.我在上面安装了ubuntu(一个Linux发行版),然后放大了系统字体.一切似乎都很完美 但最近,我在ubuntu上安装了matlab,我发现matlab不符合系统字体,matlab中的字体有原始大小,对我来说太小了.我通过修改文件 - 首选项来改变代码区域中的字体大小,但菜单栏和提示窗口中的字体对我来说仍然太小.在互联网上搜索了很长时间后,我发现在这些区域中更改字体没有任何帮助.任何人都可以帮助我吗?任何帮助赞赏!
我试图使用以下命令跳转到 vim 中的下一个 python 类或函数:
autocmd FileType python nnoremap <buffer> [[ ?^class|^\s*def<CR>
autocmd FileType python nnoremap <buffer> ]] /^class|^\s*def<CR>
Run Code Online (Sandbox Code Playgroud)
但这不起作用。Vim 提示:
Error detected while processing FileType Auto commands for "python":
E492: Not an editor command: ^\s*def<CR>
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
我正在使用 django 和精神来建立一个网站。在测试中,当我向名为 的表中插入新数据时spirit_category_category,出现以下错误:
django.db.utils.IntegrityError: duplicate key value violates unique constraint "spirit_category_category_pkey"
DETAIL: Key (id)=(1) already exists.
Run Code Online (Sandbox Code Playgroud)
请注意,表中已经有两个其他记录,其 ID 为1和2。所以插入Key(id)=(1)当然行不通。但是执行的sql不包括id字段。即是Key (id)=(1)postgresql自动生成的,为什么生成一个已经存在的id?
为了找出原因,我在 postgresql 中运行了以下命令:
test_spiritdb=# select start_value, last_value, max_value from spirit_category_category_id_seq;
start_value | last_value | max_value
-------------+------------+---------------------
1 | 1 | 9223372036854775807
(1 row)
Run Code Online (Sandbox Code Playgroud)
所以基本上,last_valueis 1,所以Key (id)=(1)每次都会生成 postgresql ,我尝试将其更改为 3,一切都很好。
test_spiritdb=# alter sequence spirit_category_category_id_seq restart with 3;
Run Code Online (Sandbox Code Playgroud)
测试通过了。但它是一个测试,所以修改一个测试表是没有意义的,因为每次测试都会删除并重新创建测试数据库,所以下次测试会再次失败,因为 …
我有一个位于server_c上的Oracle数据库,只有在server_b上才能访问.因此,为了连接到这个Oracle数据库,我必须首先通过SSH登录到server_b,然后键入以下命令连接到它.
sqlplus username/password@server_c:1571/service
Run Code Online (Sandbox Code Playgroud)
我想在DataGrip中连接到Oracle数据库,首先我在SSH/SSL选项卡中输入我的用户名和密码.
然后我输入了一般的数据库信息.
我觉得没问题,但是当我点击它时Test Connection,我收到了一个错误.
错误:连接到Oracle - @server_c失败.ORA-00604:递归SQL级别1 ORA-20001发生错误:服务器不在有效应用程序服务器列表中ORA-06512:第28行
如果我尝试直接连接到数据库而不事先登录到server_b,则会发生此错误.换句话说,我认为DataGrip在连接数据库之前不会先连接到SSH隧道.
我不确定我SSH/SSL是否正确地以这种方式使用标签.因此,如果你知道为什么它不起作用或任何解决方案,请告诉我.
我正在阅读“有效的Java”,这是这本书的引文:
接口定义类型,可能提供一些默认方法,而骨架实现类在原始接口方法之上实现其余的非原始接口方法。扩展骨架实现可以使大部分工作脱离实现接口。这是模板方法模式。
作者正在谈论一些抽象类,例如AbstractCollection,AbstractSet等,它们实现了一个接口并提供了一些基本的实现。但是,我不知道引用的内容non-primitive interface methods和内容primitive interface methods。我知道Java中的“原始类型”,但是什么是“原始方法”?
考虑以下代码。我想模拟self.get_value,在中调用foo.verify_client()
import unittest
import mock
def mock_get_value(self, value):
return 'client'
class Foo:
def __init__(self):
pass
def get_value(self, value):
return value
def verify_client(self):
client = self.get_value('client')
return client == 'client'
class testFoo(unittest.TestCase):
@mock.patch('self.get_value', side_effect = mock_get_value, autospec = True)
def test_verify_client(self):
foo = Foo()
result = foo.verify_client()
self.assertTrue(result)
if __name__ == "__main__":
unittest.main()
Run Code Online (Sandbox Code Playgroud)
但是我失败了,错误如下。
E
======================================================================
ERROR: test_verify_client (__main__.testFoo)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/apps/Python/lib/python2.7/site-packages/mock/mock.py", line 1297, in patched
arg = patching.__enter__()
File "/apps/Python/lib/python2.7/site-packages/mock/mock.py", line 1353, …Run Code Online (Sandbox Code Playgroud) 有时我想在另一个文本编辑器中修改文件并切换回来,但 Sublime Text 3 不会重新加载我之前编辑的当前文件。
如何让它自动重新加载文件?