赵乐ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 2 3 4 5 6 7 ··· 11 下一页

2013年3月18日

摘要: 这个系列的博客是学习《Learn Python the Hard Way》中做的笔记。1. 由于今天需要看的five chapters是复习性质的内容,把前边的内容综合了一下,所以没有新内容只把代码贴在这View Code print "Let's practice everything."print "You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs."poem = """\t The lovely 阅读全文
posted @ 2013-03-18 00:14 赵乐ACM 阅读(749) 评论(0) 推荐(0) 编辑

2013年3月16日

摘要: 1. 文件写操作文件写操作,需要在打开文件的时候添加参数,如open("filename", "w")以下是对文件操作的函数小结close -- Closes the file. Like File->Save.. in your editor.read -- Reads the contents of the file, you can assign the result to a variable.readline -- Reads just one line of a text file.truncate -- Empties the fil 阅读全文
posted @ 2013-03-16 12:10 赵乐ACM 阅读(250) 评论(0) 推荐(0) 编辑

2013年3月15日

摘要: 1. python输入raw_input()函数。a = raw_input() #得到的是字符串a = int(raw_input()) #如果想得到int,只能这样如果输入特殊字符,比如\t \n等,会和输入一样输出,%r会输出\\t、\\n,%s会输出\t、\nView Code print "How old are you?"age = raw_input()print "How tall are you?"height = raw_input()print "How much do you weight?"weight = 阅读全文
posted @ 2013-03-15 22:33 赵乐ACM 阅读(866) 评论(0) 推荐(0) 编辑

2013年3月14日

摘要: 1. String类型输出,看示例x = "There are %d types of people" % 10binary = "binary"do_not = "don't"y = "Those who know %s and those who %s" % (binary, do_not)z = "Those who know %r and those who %r" % (binary, do_not)print xprint yprint zprint "I said 阅读全文
posted @ 2013-03-14 16:24 赵乐ACM 阅读(259) 评论(0) 推荐(0) 编辑

2013年3月13日

摘要: 1. 脚本中写中文出现乱码,用以下可以解决。参考http://www.python.org/dev/peps/pep-0263/ # coding=<encoding name> #!/usr/bin/python # -*- coding: <encoding name> -*- #!/usr/bin/python # vim: set fileencoding=<encoding name> :2. 输出格式,先看代码my_name = 'Zed A. Shaw'print "Let's talk a... 阅读全文
posted @ 2013-03-13 23:28 赵乐ACM 阅读(387) 评论(0) 推荐(0) 编辑

2013年3月12日

摘要: 1. 在页面上显示PHP的worning、notice等的代码error_reporting(E_ALL);ini_set("display_errors", TRUE); 2. 写php代码的时候,应该尽量避免调用函数,比如<?php if (...) { print "<b>hello</b>"; }?>应该写成<?php if (...) : ?> <b>hello</b><?php endif ?>这样就减少了函数调用,可以提高效率3. 如果遇到可能会出错的地方, 阅读全文
posted @ 2013-03-12 23:26 赵乐ACM 阅读(171) 评论(0) 推荐(0) 编辑

2013年3月11日

摘要: httpclient登录新浪微博(非SDK方式)分享此文章苦逼的折腾了快一星期,总算把新浪微博rsa加密登录折腾ok了,这里需要注意的是httpclient最好用4.0的,否则cookie管理很是问题。进入正题,最近新浪微博更新了sso登录方式,加密算法变成了rsa,获取nonce和servertime,pubkey,这里涉及到rsa加密,通常用java进行rsa加密一般都是从文件读取公钥信息或者是base64编码的公钥信息转换成key,然后进行加密,但是新浪给的不是base64加密,而是给的一个N(参见RSA加密算法,RSA加密算法),而我先入为主,把新浪给的pubkey当作base64编码 阅读全文
posted @ 2013-03-11 23:13 赵乐ACM 阅读(7483) 评论(0) 推荐(0) 编辑

2013年3月9日

摘要: 1. 为什么给一个URL发送的http请求里会有host这一项Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3Accept-Encoding:gzip,deflate,sdchAccept-Language:zh-CN,zh;q=0.8Connection:keep-aliveCookie:************************Host:www.google.com.hkUser-Agent:Mozilla/5.0 ( 阅读全文
posted @ 2013-03-09 20:36 赵乐ACM 阅读(176) 评论(0) 推荐(0) 编辑

2013年1月8日

摘要: 用了大半天时间才了解如何使用httpclient来进行https访问,现记录,已备后忘。 httpclient完全支持ssl连接方式。通常,如果不需要进行客户端认证和服务器端认证的ssl连接,httpclient的处理方式是和http方式完全一样。 现在这里是讲的是需要客户端认证数字证书时的httpclient处理方式(因为需要客户端认证时,连接会被主动关闭)。 1。使用ie访问你要连结的url地址,这时你会看到弹出一个询问是否继续和服务器建立连接的对话框(安全警报)。选择“查看证书”->“详细信息”->“复制文件到”导出数字证书(例: server.cer或server.crt) 阅读全文
posted @ 2013-01-08 23:36 赵乐ACM 阅读(2054) 评论(0) 推荐(0) 编辑

摘要: 1.拳头之Get/Post拳头是最基本的一重武器,也是最重要的,好比练武之人必须先扎稳马步。java 代码HttpClienthttpclient=newHttpClient();//创建一个客户端,类似打开一个浏览器GetMethodgetMethod=newGetMethod("http://www.blablabla.com");//创建一个get方法,类似在浏览器地址栏中输入一个地址intstatusCode=httpclient.executeMethod(getMethod);//回车——出拳!System.out.println("response= 阅读全文
posted @ 2013-01-08 23:24 赵乐ACM 阅读(2871) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 11 下一页