
Python
lingex
这个作者很懒,什么都没留下…
展开
-
Text
[code="python"] Example 3-1. Python single/double quote comparison In [1]: s = "This is a string with 'quotes' in it" In [2]: s Out[2]: "This is a string with 'quotes' in it" In [3]: s = 'This is...原创 2010-09-11 18:04:32 · 99 阅读 · 0 评论 -
Documentation and Reporting
[code="python"] Example 4-1. Retrieving email using POP3 #!/usr/bin/env python import poplib username = 'someuser' password = 'S3Cr37' mail_server = 'mail.somedomain.com' p = poplib.POP3(mail_s...原创 2010-09-11 21:07:50 · 108 阅读 · 0 评论 -
Networking
[code="python"] Example 5-1. TCP port checker #!/usr/bin/env python import socket import re import sys def check_server(address, port): #create a TCP socket s = socket.socket() ...原创 2010-09-11 21:36:11 · 116 阅读 · 0 评论 -
Data
[code="python"] Example 6-1. Exploring common OS module data methods In [1]: import os In [2]: os.getcwd() Out[2]: '/private/tmp' In [3]: os.mkdir("/tmp/os_mod_explore") In [4]: os.listdir("/tmp...原创 2010-09-11 21:55:22 · 101 阅读 · 0 评论 -
Python VIM 开发环境配置
1. VIM python 自动补全插件:pydiction 这是一个相当不错的 Python 代码自动完成的脚本。 可以实现下面python代码的自动补全: 简单python关键词补全 python 函数补全带括号 python 模块补全 python 模块内函数,变量补全 from module import sub-module 补全 pydiction 插件安装...原创 2010-09-12 15:01:59 · 243 阅读 · 0 评论 -
python对操作系统的目录和文件操作
[code="python"] 1.ls os.listdir(os.getcwd()) 2.cd 更改当前目录 os.chdir("/tmp") 3.touch 创建文件 f=open('/tmp/123','w') f.close 4.mkdir 创建目录 os.mkdir('/tmp/123') 5.mkdir -p 创建多级目录 os.makedirs...原创 2010-10-04 10:23:07 · 124 阅读 · 0 评论 -
re模块的方法
[code="python"] 一.re.match re.match 尝试从字符串的开始匹配一个模式,如:下面的例子匹配第一个单词。 import re text = "JGood is a handsome boy, he is cool, clever, and so on..." m = re.match(r"(\w+)\s", text) if m: ...原创 2010-10-04 15:08:12 · 161 阅读 · 0 评论 -
Python中文问题
转自:http://hi.baidu.com/daping_zhang/blog/item/09dda71ea9d7d21f4134173e.html 我曾经在深入浅出java中文问题 系列中研究过java的中文问题,现在中文问题已经不再羁绊我在java世界中漫游的脚步了。最近,对Python产生了浓厚的兴趣,谁知道跟中文问题这个老朋友又一次不期而遇。看来,在代码世界中,中文问...原创 2011-02-20 14:24:55 · 110 阅读 · 0 评论 -
cx_Oracle安装
1.下载安装oracle客户端 http://www.oracle.com/technetwork/indexes/downloads/index.html Oracle Database 10g Express Client 2. 配置oracle环境变量 TNS_ADMIN='C:\XEClient\network\ADMIN' ORACLE_HOME='C:\XEClient'...原创 2011-07-07 01:19:19 · 187 阅读 · 0 评论