公告版位
新版Blog peichengnote

目前分類:CODE (61)

瀏覽方式: 標題列表 簡短摘要

Code for Program to sort a linked list by swapping data in C Programming

Program to sort a linked list by swapping data - C Programming Examples and Tutorials
http://www.syntax-example.com/Code/sort-linked-list-swapping-data-2818.aspx


Code for Program to sort a linked list by swapping data in C Programming
#include <stdio.h>
#include <conio.h>
#include <alloc.h>

peicheng 發表在 痞客邦 留言(0) 人氣()

有時候想要看個一週氣象預報,
可是又不想上,中央氣象局網站看。

順手寫了個提取,中部地區一週氣象的狀態。

放在側邊欄這樣就可以比較常看到了。



peicheng 發表在 痞客邦 留言(0) 人氣()

下載了一個自動產生 pycon影音連結的python script

wget http://www.cngump.com/wp-content/uploads/2011/03/url_blip_tv.py_.zip

用的自己編的python
pcl99@gais4.cs.ccu.edu.tw[~/project/python/test][13:31](SCREEN 1)$ ~/bin/Python url_blip_tv.py
http://blip.tv/file/get/Pycon-PyCon2011DeployingWebApplicationsToTheCloud1of2113.mp4
Traceback (most recent call last):
File "url_blip_tv.py", line 26, in
html=html+"{0}

peicheng 發表在 痞客邦 留言(0) 人氣()

4. More Control Flow Tools — Python v2.7.1 documentation
http://docs.python.org/tutorial/controlflow.html#for-statements
5. Built-in Types — Python v2.7.1 documentation
http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex



peicheng 發表在 痞客邦 留言(0) 人氣()


How do I read a huge file line by line in Python, without loading the entire thing into memory first?
http://www.yak.net/fqa/171.html
by rupe

How do I read a huge file line by line in Python, without loading the entire thing into memory first?


In Python, the most common way to read lines from a file is to do the following: 

for line in open('myfile','r').readlines():
do_something(line)

peicheng 發表在 痞客邦 留言(0) 人氣()

之前想解析bitext 找了找一些作法找到python example
 
Pybtex! http://pybtex.sourceforge.net/
from pybtex.database.input import bibtex from operator import itemgetter, attrgetter import pprint parser = bibtex.Parser() bib_data = parser.parse_file('ref.bib') def sort_by_year(y, x): return int(x[1].fields['year']) - int(y[1].fields['year']) bib_sorted = sorted(bib_data.entries.items(), cmp=sort_by_year) for key, value in bib_sorted: print key print value.fields['year'] print value.fields['author'] print value.fields['title']
peicheng@PCsNB ~/project/python/pybitex $ python bitex.py wu1992fast 1992 Wu, S. and Manber, U. {Fast text searching: allowing errors} peicheng@PCsNB ~/project/python/pybitex $ cat ref.bib @article{wu1992fast, title={{Fast text searching: allowing errors}}, author={Wu, S. and Manber, U.}, journal={Communications of the ACM}, volume={35}, number={10}, pages={83--91}, issn={0001-0782}, year={1992}, publisher={ACM} }

  
 


peicheng 發表在 痞客邦 留言(0) 人氣()

python 內的print 會自動換行
再後面加上 , 就不會了。
 
#!  ~/bin/python/bin/python
file=open('text.txt');
while 1:
    lines=file.readline()
    if not lines:
        break
    print lines,

peicheng 發表在 痞客邦 留言(0) 人氣()


因為在Gentoo下emerge tools跟python都已經升級到2.6了。                                                                                                                                                     
但是Google App Engine 只支援pythone 2.5。

所以,自己去python 官網下了Python-2.5.5.tgz
tar xvf Python-2.5.5.tgz

peicheng@PCsNB ~/project/lab/Python-2.5.5 $ ./configure --prefix=/home/peicheng/project/lab/Python-2.5.5
peicheng@PCsNB ~/project/lab/Python-2.5.5 $ make && make install

peicheng 發表在 痞客邦 留言(0) 人氣()

在Gentoo下編譯之前再Win上的java file出現

java:19: warning: unmappable character for encoding utf-8
javac  javac -encoding MS950 yourfile.java
java yourfile
 


peicheng 發表在 痞客邦 留言(0) 人氣()

定義和用法
用str_rot13()函數對字符串執行的ROT13編碼。

 是一種每一個字母被另一個字母代替的方法。這個代替字母是由原來的字母向前移動 13個字母而得到的。數字和非字母字符保持不變。
語法
用str_rot13(字符串)

 參數描述

 字符串必需。規定要編碼的字符串。

peicheng 發表在 痞客邦 留言(0) 人氣()

PHP: XML to JSON 轉換程式(xml2json) | Tsung's Blog
http://plog.longwin.com.tw/post/1/454



peicheng 發表在 痞客邦 留言(0) 人氣()


廣州亞運得牌數統計
http://www.gz2010.cn/info/medal/jmedal.json

內容為:

 

var json_medal={"medal_chi":"
排名 国家/地区 总数
1 中国 105 40 36 181韩国29233688日本18423797朝鲜571022伊朗54817"};GameMedal.show_medal();-------------------------------

為了想把它濾的的好看點。
其實應該直接取得json就可以了。
使用土炮法練習。
2
3
4
5

peicheng 發表在 痞客邦 留言(0) 人氣()


廣州亞運得牌數統計
http://www.gz2010.cn/info/medal/jmedal.json

內容為:

 

var json_medal={"medal_chi":"
排名 国家/地区 总数
1 中国 105 40 36 181韩国29233688日本18423797朝鲜571022伊朗54817"};GameMedal.show_medal();-------------------------------

為了想把它濾的的好看點。
其實應該直接取得json就可以了。
使用土炮法練習。
2
3
4
5

peicheng 發表在 痞客邦 留言(0) 人氣()

轉載

//方法一

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();//引用stopwatch物件

sw.Reset();//碼表歸零

sw.Start();//碼表開始計時

/**************/

/**************/

/***目標程式***/

/**************/

peicheng 發表在 痞客邦 留言(0) 人氣()

複製既有的檔案進去project

要連src bin一起放進去
避免引用的jar檔發生錯誤

peicheng 發表在 痞客邦 留言(0) 人氣()


自主學習

----

關於學姊問到的
什麼是自學?
( 待補)


peicheng 發表在 痞客邦 留言(0) 人氣()

作者: peicheng () 看板: P_peicheng
標題: 一個一維陣列的例子
時間: Wed Nov 22 23:42:41 2006

public class Test {

public static void main(String[] args) {
int a1[] = new int[10];
int a2[] = new int[10];

peicheng 發表在 痞客邦 留言(0) 人氣()

作者: peicheng () 看板: P_peicheng
標題: sub作業擲骰子 取亂數ex用array
時間: Wed Nov 22 22:42:53 2006

public class Test {

public static void main(String[] args) {
int a1[]=new int[10];
int a2[]=new int[10];
for (int i = 0; i a1[i]=(int)(Math.random()*11)-5;

peicheng 發表在 痞客邦 留言(0) 人氣()

作者: peicheng () 看板: P_peicheng
標題: 取亂數存ARRAY
時間: Wed Nov 22 17:56:05 2006

public class Test {

public static void main(String[] args) {
int a1[]=new int[100];
int a2[]=new int[100];
for (int i = 0; i a1[i] = (int)(Math.random() * 11)-5;

peicheng 發表在 痞客邦 留言(0) 人氣()

作者: peicheng () 看板: P_peicheng
標題: 取亂數1-6 (JAVA)
時間: Wed Nov 22 17:36:32 2006

public class Test {

public static void main(String[] args) {
for (int i = 0; i int a = (int) (Math.random() * 6);
System.out.println(a+1);

peicheng 發表在 痞客邦 留言(0) 人氣()