小编gag*_*ina的帖子

再次转换为UTF-8

我有这串 Traor\u0102\u0160

Traor\u0102\u0160应该产生Traoré。然后Traoréutf-8解码应该产生Traorè

我如何将其转换为Traorè

什么样的字符是Traor\u0102\u0160?Unicode?

我已经阅读了很多http://docs.python.org/howto/unicode.html#encodings。但是我还是很困惑。

我通过以下请求获取此数据:

import json
import requests

# making a request to get this json
r = requests.get('http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/web/199074.json')
print r.json
Run Code Online (Sandbox Code Playgroud)

#! /usr/bin/env python
# -*- coding: utf-8 -*-
import json
import requests

headers = {'Content-Type': 'application/json'}

r = requests.get('http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/web/199074.json', headers=headers)


print r.content

#prints
{"Item":{"FirstName":"Lacina","LastName":"Traoré","CommonName":null,"Height":"203","DateOfBirth":{"Year":"1990","Month":"8","Day":"20"},"PreferredFoot":"Left","ClubId":"100766","LeagueId":"67","NationId":"108","Rating":"78","Attribute1":"79","Attribute2":"71","Attribute3":"45","Attribute4":"69","Attribute5":"50","Attribute6":"72","Rare":"1","ItemType":"PlayerA"}}
Run Code Online (Sandbox Code Playgroud)

基本上,我需要设置发送严格的标题。

谢谢你们

python utf-8 character-encoding

2
推荐指数
1
解决办法
6077
查看次数

JQUERY如何从动态div获取id名称?

我有两个动态生成(来自PHP文件)div.这个div是这样的:

<div id="x" class="myclass"></div>
<div id="y" class="myclass"></div>
Run Code Online (Sandbox Code Playgroud)

其中X和Y是从php文件动态生成的数字.我怎样才能得到这个id(数字),例如,我点击这个div?

我试过这样的方式:

$('.myclass').click(function(){

alert(this.attr("id"));

});
Run Code Online (Sandbox Code Playgroud)

但是这样我只得到第一个id(myclasses的第一个元素).

我该如何解决?

html php jquery

1
推荐指数
2
解决办法
2万
查看次数

正则表达式在sed中替换给定特定格式的URL的部分

我在使用sed做一个简单的正则表达式时遇到了一些问题.

我要在sql文件中做一些替换,我正在尝试使用sed.

我应该替换一些链接的url.链接采用以下格式:

万维网.site1 .com/blog/2012/12/12

我想在所有链接中将site1替换为site2.

为了找到这些链接,我写了以下正则表达式:

(site1.com)\/blog\/\d{4}\/\d{2}\/\d{2}
Run Code Online (Sandbox Code Playgroud)

而且好像很适合.

使用sed做替换的事情我写了下面的代码

cat back.sql | sed 's:(site1.com)\/blog\/\d{4}\/\d{2}\/\d{2}:site2.com:' > fixed.sql
Run Code Online (Sandbox Code Playgroud)

但它似乎不起作用..

regex linux bash sed

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

在dict列表中的问题

class MyOwnClass:

  # list who contains the queries
  queries = []

  # a template dict
  template_query = {}
  template_query['name'] = 'mat'
  template_query['age'] = '12'

obj = MyOwnClass()

query = obj.template_query
query['name'] = 'sam'
query['age'] = '23'
obj.queries.append(query)

query2 = obj.template_query
query2['name'] = 'dj'
query2['age'] = '19'
obj.queries.append(query2)

print obj.queries
Run Code Online (Sandbox Code Playgroud)

它给了我

[{'age': '19', 'name': 'dj'}, {'age': '19', 'name': 'dj'}]
Run Code Online (Sandbox Code Playgroud)

虽然我希望有

[{'age': '23'  , 'name': 'sam'}, {'age': '19', 'name': 'dj'}]
Run Code Online (Sandbox Code Playgroud)

我想为这个列表使用一个模板,因为我会经常使用它,并且有一些默认变量不需要更改.

为什么这样做会改变template_query自己?我是python的新手,我很困惑.

python dictionary list

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

如何在vim中禁用制表符补全?

从今天早上开始,我一直在寻找解决方案,但没有任何运气。你能告诉我如何禁用按TAB时出现的这个东西吗?

在此输入图像描述

这是我的 .vimrc 文件:

set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" This is the Vundle package, which can be found on GitHub.
" For GitHub repos, you specify plugins using the
" 'user/repository' format
Plugin 'gmarik/vundle'

" We could also add repositories with a ".git" extension
Plugin 'scrooloose/nerdtree.git'

" To get plugins from Vim Scripts, you can reference the plugin
" by name as it appears on the site
Plugin 'Buffergator'

" Syntax hihgler
Plugin 'scrooloose/syntastic'


" Pluginper …
Run Code Online (Sandbox Code Playgroud)

vim tabs autocomplete

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

标签 统计

python ×2

autocomplete ×1

bash ×1

character-encoding ×1

dictionary ×1

html ×1

jquery ×1

linux ×1

list ×1

php ×1

regex ×1

sed ×1

tabs ×1

utf-8 ×1

vim ×1