我正在编写一个基于小瓶子的站点,我想使用Ajax将数据从客户端发送到服务器.到目前为止,我只使用Ajax请求从服务器检索数据.这次我想通过POST请求提交数据.
这是烧瓶侧的接收器,我将其减少到几乎没有记录消息,以避免在此路由的实现中出现任何不必要的错误:
@app.route("/json_submit", methods=["POST"])
def submit_handler():
# a = request.get_json(force=True)
app.logger.log("json_submit")
return {}
Run Code Online (Sandbox Code Playgroud)
提交ajax请求时,flask会给我400错误
127.0.0.1 - - [03/Apr/2014 09:18:50] "POST /json_submit HTTP/1.1" 400 -
Run Code Online (Sandbox Code Playgroud)
我也可以在浏览器的Web开发人员控制台中看到这一点
为什么烧瓶没有submit_handler使用请求中提供的数据进行调用?
var request = $.ajax({
url: "/json_submit",
type: "POST",
data: {
id: id,
known: is_known
},
dataType: "json",
})
.done( function (request) {
})
Run Code Online (Sandbox Code Playgroud) 我一直在尝试优秀的媒体编辑器.我一直遇到的问题是我似乎无法获得"工作"的链接.
最简单的是,这里有一些用于演示问题的HTML/JS:
HTML:
<html>
<head>
<script src="//cdn.jsdelivr.net/medium-editor/latest/js/medium-editor.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/medium-editor/latest/css/medium-editor.min.css" type="text/css" media="screen" charset="utf-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/medium-editor/latest/css/themes/beagle.min.css" type="text/css">
</head>
<body>
<div class='editable'>
Hello world. <a href="http://www.google.com">link</a>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
var editor = new MediumEditor('.editable');
Run Code Online (Sandbox Code Playgroud)
这个小提琴演示了这个问题(使用上面的代码).
在我看来,点击链接应该带我到链接的href目标位置.使用该链接的唯一方法是右键单击并在新选项卡或新窗口中打开 - 我不想让我的用户这样做.
我觉得我必须在配置中忽略一些简单的东西(Anchor Preview Options或Anchor Form Options).不幸的是,我没有看到它.
在我的实际应用中,我没有使用jQuery,但我正在使用angularjs.如果不存在严格的媒体编辑器答案,我可以回退使用基本的JS或angularjs提供的任何东西.
我有一系列横跨经度= 0线的纬度/经度点.我想使用matplotlib Axes类来绘制这些,它们"包裹"水平尺寸,这样当朝向l = 360时,l = 1处的点被绘制为等于l = 361.理想情况下,我也喜欢定义平移/缩放动作的东西,所以我可以交互使用绘图.
我知道可以在matplotlib中定义自定义投影,但我还没有找到实现所有这些功能的圆柱投影的等价物.我宁愿不用basemap.有谁知道这样的事情是否存在?
我有一些代码在编译时给我重定位错误,下面是一个说明问题的示例:
program main
common/baz/a,b,c
real a,b,c
b = 0.0
call foo()
print*, b
end
subroutine foo()
common/baz/a,b,c
real a,b,c
integer, parameter :: nx = 450
integer, parameter :: ny = 144
integer, parameter :: nz = 144
integer, parameter :: nf = 23*3
real :: bar(nf,nx*ny*nz)
!real, allocatable,dimension(:,:) :: bar
!allocate(bar(nf,nx*ny*nz))
bar = 1.0
b = bar(12,32*138*42)
return
end
Run Code Online (Sandbox Code Playgroud)
编译这个gfortran -O3 -g -o test test.f,我得到以下错误:
relocation truncated to fit: R_X86_64_PC32 against symbol `baz_' defined in COMMON section in …Run Code Online (Sandbox Code Playgroud) 我试过了
import urllib.request
Run Code Online (Sandbox Code Playgroud)
要么
import urllib
Run Code Online (Sandbox Code Playgroud)
我的urllib的路径是
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/__init__.py
我想知道urlopen在哪里,或者我的python模块指向错误的文件?
我有一堆使用"特殊方法"的类:
class Foo(object):
"Foo docstring"
attr1 = "Attribute!" #: first attribute
attr2 = "Another Attribute!" #: second attribute
def __init__(self):
self.x = 12
def say_hello(self):
"""
say_hello(self) -> None
Issue a friendly greeting.
"""
print "Hello! x is {0}".format(self.x)
def __contains__(self,other):
"""Implement ``other in self``"""
return other == self.x
Run Code Online (Sandbox Code Playgroud)
现在我想使用Sphinx和autodoc为此生成html文档.我如何告诉Sphinx记录__contains__?我尝试添加
autodoc_default_flags = ['members', 'undoc-members', 'special-members']
Run Code Online (Sandbox Code Playgroud)
到conf.py,但也包括__dict__我绝对不想要的.
目前,该myproject.rst文件的相关部分如下所示:
.. automodule:: myproject.foomodule
:members:
:undoc-members:
:show-inheritance:
Run Code Online (Sandbox Code Playgroud)
编辑添加
.. automodule:: myproject.foomodule
:members:
:undoc-members:
:show-inheritance:
.. …Run Code Online (Sandbox Code Playgroud) 我想编写一个Python函数来改变其中一个参数(这是一个列表,即可变).像这样的东西:
def change(array):
array.append(4)
change(array)
Run Code Online (Sandbox Code Playgroud)
我更熟悉传递值而不是Python的设置(无论你决定调用它).所以我通常会写这样的函数:
def change(array):
array.append(4)
return array
array = change(array)
Run Code Online (Sandbox Code Playgroud)
这是我的困惑.由于我可以改变参数,第二种方法似乎是多余的.但第一个感觉不对.此外,我的特定功能将有几个参数,其中只有一个会改变.第二种方法清楚地说明了哪个参数正在改变(因为它被赋值给变量).第一种方法没有给出任何指示.有会议吗?哪个更好'?谢谢.
我正在尝试重新实现其中一个matlab工具箱.他们在那边使用fft.当我对相同的数据执行相同的操作时,我会得到与matlab不同的结果.看看:
MATLAB:
Msig =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
fft(Msig.')
Columns 1 through 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
Columns 5 through 6
1.0000 0
0 - 1.0000i 0
-1.0000 0
0 + 1.0000i 0
Run Code Online (Sandbox Code Playgroud)
PYTHON:
Msig=
array([[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ …Run Code Online (Sandbox Code Playgroud) >>> import re
>>> s = 'this is a test'
>>> reg1 = re.compile('test$')
>>> match1 = reg1.match(s)
>>> print match1
None
Run Code Online (Sandbox Code Playgroud)
在Kiki中匹配s结束时的测试.我错过了什么?(我也试过re.compile(r'test$'))
我正在quadmesh创建一个简单的极坐标投影图.这是一个最小的脚本,基本上产生了我正在尝试做的事情:
from __future__ import unicode_literals
import numpy as np
import matplotlib.pyplot as plt
def make_plot(data,fig,subplot):
nphi,nt = data.shape
phi_coords = np.linspace(0,np.pi*2,nphi+1) - np.pi/2.
theta_coords = np.linspace(0,np.radians(35),nt+1)
ax = fig.add_subplot(subplot,projection='polar')
ax.set_thetagrids((45,90,135,180,225,270,315,360),(9,12,15,18,21,24,3,6))
ax.set_rgrids(np.arange(10,35,10),fmt='%s\u00b0')
theta,phi = np.meshgrid(phi_coords,theta_coords)
quadmesh = ax.pcolormesh(theta,phi,data)
ax.grid(True)
fig.colorbar(quadmesh,ax=ax)
return fig,ax
a = np.zeros((360,71)) + np.arange(360)[:,None]
b = np.random.random((360,71))
fig = plt.figure()
t1 = make_plot(a,fig,121)
t2 = make_plot(b,fig,122)
fig.savefig('test.png')
Run Code Online (Sandbox Code Playgroud)
上面的脚本创建了一个如下所示的图:

我希望颜色条能够:
是否有任何技巧可以使这项工作正常?(请注意,这个布局不是我将使用的唯一一个 - 例如我可能会使用1x2布局或4x4布局......似乎应该有一些方法可以将颜色条缩放到与相关情节...)
python ×8
javascript ×2
matplotlib ×2
ajax ×1
fft ×1
flask ×1
fortran ×1
gfortran ×1
jquery ×1
layout ×1
matlab ×1
mutable ×1
numpy ×1
projection ×1
python-3.x ×1
regex ×1
scipy ×1
urllib ×1
urlopen ×1
x86-64 ×1