小编tom*_*ton的帖子

如何让Sphinx忽略我的文档字符串中的GPL通知?

我正在使用Sphinx来记录我的Python包.当我在我的模块上使用automodule指令时:

.. automodule:: mymodule
:members:
Run Code Online (Sandbox Code Playgroud)

它会打印包括文档字符串中的GPL通知在内的所有内容.有没有办法告诉Sphinx忽略docstring/GPL还是应该把它留在文档中?

python docstring python-sphinx

8
推荐指数
1
解决办法
888
查看次数

Javascript无法正确解析JSON中的大数字

我正在以JSON格式从网络服务器传回已批准的推文列表.当我转到URL时:http://localhost:8000/showtweets/?after_id=354210796420608003在我的浏览器中,我得到以下JSON:

   [{
    "date": "2013-07-08T12:10:09",
    "text": "#RaspberryPi ist auf dem Weg :-)",
    "author_pic_url": "http://a0.twimg.com/profile_images/1315863231/twitter_normal.jpg",
    "id": 354210796420608004,
    "author": "switol"
}]
Run Code Online (Sandbox Code Playgroud)

其ID为:354210796420608004.

当我从Javascript进行GET调用时,数字会发生变化:

function TweetUpdater() {
}

TweetUpdater.latest_id = 0;
TweetUpdater.undisplayed_tweets = new Array();

TweetUpdater.prototype.get_more_tweets = function () {
    // var since_id = parseFloat(TweetUpdater.get_latestlatest_id;
    // alert(since_id);
    var get_tweets_url = "/showtweets/?after_id="+TweetUpdater.latest_id;
    $.get(get_tweets_url, function (tweets) {
        if (tweets.length > 0) {

            /////////////////////////////////////////////////////////
            alert(tweets[0].id+", "+ tweets[0].text); <<<<< THIS LINE
            /////////////////////////////////////////////////////////

            TweetUpdater.latest_id = tweets[0].id;
            for (var i = 0; i < tweets.length; i++) …
Run Code Online (Sandbox Code Playgroud)

javascript json

7
推荐指数
1
解决办法
5058
查看次数

在 Bash 中,我应该使用声明而不是本地和导出吗?

我最近发现了declareBash 内置函数,它声明具有局部作用域的变量,也可用于导出变量甚至设置类型。

# bar an baz have local scope
foo()
{
    declare bar
    local baz
}

# bing and bong are both exported
declare -x bing
export bong

# i is an integer, j is read-only integer
declare -i i=0
declare  -ri j=10
Run Code Online (Sandbox Code Playgroud)

我已经开始在任何地方使用它并停止使用本地和导出。那么,为什么localexport甚至存在吗?

bash

4
推荐指数
2
解决办法
4900
查看次数

AJAX和Python错误 - 请求的资源上没有"Access-Control-Allow-Origin"标头

我正在构建一个可以使用AJAX与简单的Python Web服务器通信的Javascript库.

这是Web服务器类:

class WebHandler(http.server.BaseHTTPRequestHandler):

    def parse_POST(self):
        ctype, pdict = cgi.parse_header(self.headers['content-type'])
        if ctype == 'multipart/form-data':
            postvars = cgi.parse_multipart(self.rfile, pdict)
        elif ctype == 'application/x-www-form-urlencoded':
            length = int(self.headers['content-length'])
            postvars = urllib.parse.parse_qs(self.rfile.read(length),
                                             keep_blank_values=1)
        else:
            postvars = {}
        return postvars

    def do_POST(self):
        postvars = self.parse_POST()

        print(postvars)

        # reply with JSON
        self.send_response(200)
        self.send_header("Content-type", "application/json")
        self.end_headers()
        json_response = json.dumps({'test': 42})
        self.wfile.write(bytes(json_response, "utf-8"))
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的Javascript方法:

var send_action = function() {
    var url = "http://192.168.1.51:8000";
    var post_data = {'gorilla': 'man'};

    $.post(url, post_data, function(data) {
        alert("success");

    })
      .done(function(data) {
        alert("second …
Run Code Online (Sandbox Code Playgroud)

javascript python ajax jquery

3
推荐指数
1
解决办法
7392
查看次数

标签 统计

javascript ×2

python ×2

ajax ×1

bash ×1

docstring ×1

jquery ×1

json ×1

python-sphinx ×1