随笔分类 -  [32] Python

上一页 1 ··· 16 17 18 19 20
摘要:《python基础教程(第二版)》学习笔记 基础部分(第1章)python常用的IDE:Windows: IDLE(gui), Eclipse+PyDev; Python(command line);Linux/Unix: python1/2=0 # 整除结果为0from __future__ im... 阅读全文
posted @ 2014-10-15 17:13 emanlee 阅读(936) 评论(0) 推荐(0)
摘要:num_lines = sum(1 for line in open(input_file_name)) 阅读全文
posted @ 2014-08-02 10:34 emanlee 阅读(3914) 评论(0) 推荐(0)
摘要:1.open 打开文件使用open打开文件后一定要记得调用文件对象的close()方法。比如可以用try/finally语句来确保最后能关闭文件。 file_object = open('D:\test.txt') try: all_the_text = file_object.read( ) fi 阅读全文
posted @ 2014-07-27 18:22 emanlee 阅读(477) 评论(0) 推荐(0)
摘要:PyDev for Eclipse, 经过测试,一般在线安装会失败(不能访问某些网站所致)以下为离线安装步骤1 下载 PyDev 2.8.2, 链接:http://sourceforge.net/projects/pydev/files/2 解压 PyDev 2.8.2 文件到 ...\MyEcli... 阅读全文
posted @ 2014-07-24 16:13 emanlee 阅读(2957) 评论(0) 推荐(0)
摘要:#!/usr/bin/python## get subprocess module import subprocess## call date command ##p = subprocess.Popen("date", stdout=subprocess.PIPE, shell=True)## T... 阅读全文
posted @ 2014-06-19 10:44 emanlee 阅读(2532) 评论(0) 推荐(0)
摘要:import subprocessoutput =Popen(["mycmd","myarg"], stdout=PIPE).communicate()[0]import subprocessp = subprocess.Popen(['ls','-a'], stdout=subprocess.PI... 阅读全文
posted @ 2014-06-01 17:04 emanlee 阅读(2882) 评论(0) 推荐(0)
摘要:Python提供的基本数据类型主要有:布尔类型、整型、浮点型、字符串、列表、元组、集合、字典、日期等等函数 描述 type(x) x的数据类型 int(x [,base ]) 将x转换为一个整数 long(x [,base ]) 将x转换为一个长整数 float(x ) 将x转换到一个浮点数 ... 阅读全文
posted @ 2014-05-31 11:38 emanlee 阅读(613) 评论(0) 推荐(0)
摘要:import os os.path.isfile('test.txt') # 如果不存在就返回False os.path.exists(directory) # 如果目录不存在就返回Falseos.makedirs(targetDir) os.path.join(targetDir, fi... 阅读全文
posted @ 2014-03-21 21:25 emanlee 阅读(838) 评论(0) 推荐(0)
摘要:生成字符串变量str='python String function' 字符串长度获取:len(str)例:print '%s length=%d' % (str,len(str))连接字符串sStr1 = 'strcat'sStr2 = 'append'sStr1 += sStr2print sS 阅读全文
posted @ 2014-03-21 21:20 emanlee 阅读(40557) 评论(1) 推荐(4)
摘要:1.格式化输出整数python print也支持参数格式化,与C言的printf似,strHello = "the length of (%s) is %d" %(Hello World,len(Hello World))print strHello#输出果:the length of (Hello... 阅读全文
posted @ 2014-03-21 18:57 emanlee 阅读(846) 评论(0) 推荐(0)
摘要:python中 getopt 模块 (import getopt),该模块是专门用来处理命令行参数的函数getopt(args, shortopts, longopts = [])参数args一般是sys.argv[1:]shortopts 短格式 (-) longopts 长格式(--) 命令行中... 阅读全文
posted @ 2013-11-20 21:56 emanlee 阅读(542) 评论(0) 推荐(0)
摘要:错误:eclipse+pydev 配置出错,就是在选择python interpreter那一步:See error log for details.com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: ... 阅读全文
posted @ 2013-08-17 18:30 emanlee 阅读(640) 评论(0) 推荐(0)
摘要:from Tkinter import * root = Tk() root.mainloop()运行出现错误:>>> Traceback (most recent call last): File "E:/××××/Python/test", line 1, in f... 阅读全文
posted @ 2011-07-01 17:38 emanlee 阅读(5121) 评论(0) 推荐(0)

上一页 1 ··· 16 17 18 19 20