随笔分类 - 【27】Python
摘要:1.第一步 下载py文件:https://bootstrap.pypa.io/ez_setup.py #!/usr/bin/env python """ Setuptools bootstrapping installer. Maintained at https://github.com/pypa/setuptools/tree/bootstrap. Run thi...
阅读全文
摘要:Py2exe 64位下载地址:http://download.csdn.net/detail/henujyj/8532827 Py2exe 32位下载地址:https://sourceforge.net/projects/py2exe/files/ 以下程序执行的结果是将hello.py程序打包成hello.exe可执行文件 第一步,编写hellp.py: #-*_coding...
阅读全文
摘要:下载MySQLdb:http://www.codegood.com/downloads 1.简单查询 #!/usr/bin/python # -*- coding: UTF-8 -*- import MySQLdb #打开数据库连接 con = MySQLdb.connect('localhost', 'root', '123456','test') #使用cursor()方法获取操...
阅读全文
摘要:1.常用符号 . 匹配任意字符 * 匹配前一个字符0次或无限次 ? 匹配前一个字符0次或1次 .* 贪心算法 .*? 非贪心算法 ()...
阅读全文
摘要:1.创建一个类 class Employee: empCount = 0 def __init__(self,name,salary): self.name = name self.salary = salary Employee.empCount +=1 def displayEmployee(self): ...
阅读全文
摘要:1.读取键盘输入 msg = raw_input("Please enter :") print "you input ",msg #可接受Python表达式作为输入 msg2 = input("请输入:") print "你输入了",msg2 2.读文件 fo = open("foo.txt","r") print fo.read() fo.close() 3.写文件 ...
阅读全文
摘要:1.介绍 函数代码块以def关键字开头,后接函数标识符名称和圆括号; return[表达式]结束函数,不带表达式的return,默认返回None 2.函数的简单调用 def printme(str): print str return printme(11) 3.传递参数 所有参数在Python里都是按引用传递的 def changeme(mylist...
阅读全文
摘要:输出当前时间 import time#引入time模块 print time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()) 输出日历 import calendar; cal = calendar.month(2016,1); print cal; 进度条 import sys import time def vi...
阅读全文
摘要:一、概要 二、数字类型(Numbers) 1.Python支持的数字类型 int(有符号整型) long(长整型) float(浮点型) complex(复数) 2.类型转换 int(x ) #将x转换为一个整数 long(x) #将x转换为一个长整数 float(x ) ...
阅读全文
摘要:PTVS下载地址:https://pytools.codeplex.com/releases/view/109707 Python下载地址:https://www.python.org/downloads/release/python-351/ API地址:http://python.usyiyi.cn/ VS下配置环境
阅读全文
摘要:除法 >>> 8 / 5 1 >>> 8 / 5.0 1.6 >>> 8.0 / 5 1.6 >>> 8 // 5.0 1.0 余数 >>> 8 % 5 2 **运算符 >>> 5 ** 2 25 =运算符 >>> width = 20 >>> height = 5*9 >>> width * height 900 _...
阅读全文

浙公网安备 33010602011771号