This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uni=unicode('apple,orange') | |
print uni | |
print type(uni) | |
_str=uni.encode('utf-8') | |
print _str | |
print type(_str) | |
_list=list(_str.split(',')) | |
print _list | |
print ','.join(_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
import sys | |
import glob | |
import os | |
script=argv | |
print os.path.abspath(sys.argv[0])#使用__file__时,命令行和直接运行结果不同,不明白 | |
path=os.path.abspath(sys.argv[0]) | |
#这里sys.argv[0]得到的是相对路径,需要取一下绝对路径 | |
print type(path) | |
print path+r"../*.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
#使用静态方法,装饰器 | |
from sys import argv | |
import sys | |
import glob | |
import os | |
script,language=argv#return as strings | |
#TODO:行号 | |
path=os.path.abspath(sys.argv[0]) | |
print path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
#从excel中读取中文,然后写入到po文件中,需要手动复制开头的说明文件,否则poedit不能正常读取 | |
import xlrd | |
workbook = xlrd.open_workbook('Cura_copy.xls')#打开一个excel | |
sheet = workbook.sheet_by_name(u'sheet1')#获取一个工作表 | |
buf=sheet.col_values(1) | |
for i in range(0,len(buf)): | |
buf[i]=unicode(buf[i]).encode('utf-8') | |
result=open("result.po",'w') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import re | |
#--------------------------- | |
pattern=re.compile(r'.ello')#首先编译正则表达式,主要是为了复用 | |
match=pattern.match('hello world!')#使用match来匹配 | |
if match: | |
print "-------------" | |
print match.group() | |
#-------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
__author__='Lingfeng Ai' | |
__license__='GPL' | |
import itertools | |
class GetName(object): | |
def __init__(self): | |
self.num=0 | |
def getResult_ordered(self,filename,list1,list2,list3,list4): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("input:radio").change(function(){ | |
var selectedvalue = $("input[name='group']:checked").val(); | |
$.getJSON("/static/select.json",function(data){ | |
$("#apply").empty(); | |
$.each(data,function() { | |
if (this.catagory==selectedvalue) | |
{ | |
$.each(this.subcatagory, function() { | |
$("#apply").append("<option>" + this.name + "</option>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("input:radio").change(function(){ | |
var selectedvalue = $("input[name='group']:checked").val(); | |
//使用getJSON会导致每次都从浏览器缓存里面加载json,ajax就可以实现动态的修改json并加载了 | |
$.ajax({ | |
type: "get", | |
url:'/static/select.json', | |
cache: false,//必须为false,否则同样会从缓存中加载 | |
dataType : "json", | |
success: function(data){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
#!/usr/bin/env python | |
# ---------------------------------------------------------------------------- | |
# "THE BEER-WARE LICENSE" (Revision 42): | |
# <terry.yinzhe@gmail.com> wrote this file. As long as you retain this notice you | |
# can do whatever you want with this stuff. If we meet some day, and you think | |
# this stuff is worth it, you can buy me a beer in return to Terry Yin. | |
# | |
# Now google has stop providing free translation API. So I have to switch to | |
# http://mymemory.translated.net/, which has a limit for 1000 words/day free |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class base | |
{ | |
public: | |
base(){}; | |
base(int i):base_(i){}; | |
public: |
OlderNewer