摘要: cmd输入python,进入python命令行查看输出信息:>> pythonPython 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(3531) 评论(0) 推荐(0) 编辑
摘要: import numpy as nparr = np.array([[1,2,3], [2,3,4]])print(arr)print(type(arr))print('number of dim:', arr.ndim)print('shape:', ar... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 例子:#!/usr/bin/python# -*- coding: UTF-8 -*-import time# 格式化成2016-03-20 11:45:39形式print time.strftime("%Y-%m-%d %H:%M:%S", time.lo... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(958) 评论(0) 推荐(0) 编辑
摘要: 方法1:下载、解压、进入目录,手动运行setup.py install去安装,如源码安装pip:wget http://pypi.python.org/packages/source/p/pip/pip-0.7.2.tar.gz #(替换为最新的包)tar ... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 看代码:s1 = []s2 = []print s1 is s2 # Falseprint s1 == s2 # Trueis判断引用相等性==判断对象相等性(最好只用于数比较)?Python 3.X 版本中没有 cmp 函数(用于字典元素相等性比较),... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 相当于JavaDoc。函数语句块第一行开始,第二行是空行(惯例)。可以用函数名.__doc__获取,help内置函数会获取并展示。def f(): '''Thid is function f. this is describes.''' p... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 文件:poem = '''helloworld'''f = file('book.txt', 'w') #以write模式打开文件,用于写。(写入的文件编码为UTF-8)f.write(poem)f.close()f = file('book.txt') ... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 定义类:class A: def __init__(self, name): self.name = name def say(self): print self.name def __del__(self): ... 阅读全文
posted @ 2018-12-25 09:32 xuejianbest 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 从以下网址获取python各版本:https://www.python.org/ftp/python/版本说明:rc1版rc2版不是最终版,最终版前面没有rc*字样。如:Python-2.7.13.tgz*.tgz文件是源码,需要编译安装:解压:wget h... 阅读全文
posted @ 2018-12-25 09:31 xuejianbest 阅读(539) 评论(0) 推荐(1) 编辑