Python基础
写程序的小火箭
Java后端、分布式计算、中间件技术
展开
-
python入门笔记import方法区别
拿常用的numpy函数作为例子,说明一下使用import导入模块之后的区别,导入numpy有一下三种方法from numpy import *import numpyfrom numpy import np三者都可是实现numpy函数的导入,但是在调用的时候会有区别使用from numpy import *,这是一种在写程序的时候不是特别推荐的方法,后面会讲一下不推荐的原因原创 2017-12-08 23:16:21 · 283 阅读 · 0 评论 -
python入门运算(shape 、tile 、sum)
本文档简单记录一下python一些入门函数的应用1.shape函数(求数组或者矩阵的维数)基本应用就是返回矩阵的行数与列数//3x3矩阵>>> e = eye(3) >>> e array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) >>> e.shape (3,原创 2017-12-09 22:17:55 · 550 阅读 · 0 评论 -
numpy中argsort函数用法
原文:http://blog.csdn.net/maoersong/article/details/21875705在Python中使用help帮助>>> import numpy>>> help(numpy.argsort)Help on function argsort in module numpy.core.fromnumeric:argsort(a,转载 2017-12-09 22:52:28 · 391 阅读 · 0 评论 -
Python 字典(Dictionary) get()方法
描述Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值。语法get()方法语法:dict.get(key, default=None)参数key -- 字典中要查找的键。default -- 如果指定键的值不存在时,返回该默认值值。返回值返回指定键的值,如果值不在字典中返回默认值转载 2017-12-09 23:04:26 · 337 阅读 · 0 评论 -
Pycharm中文注释出错
直接加入中文注释会提示如下错误 SyntaxError: Non-ASCII character '\xe7' in file /home/rocket531/PycharmProjects/chp2/New_KNN.py on line 7, but no encoding declared; see http://www.python.org/peps/pep-0263.html for de原创 2017-12-27 23:57:38 · 6533 阅读 · 0 评论 -
Python数据结构:序列(列表[]、元组())与映射(字典{})语法总结
一、概述:Python中两种基本的数据结构是序列和映射,序列包含:可变的列表和不可变的元组;而当序列不够用时就出现了映射:字典。列表中的元素是可以变化的,元组里面的元素一旦初始化后就不可更改。列表和元组只是一类元数据的集合体,还不能满足通过名字引用值的数据,故字典就充当了这个功能角色。二、列表(list):1.写法示例:x=[1,2,3,4,5] y=['1','2','3','4转载 2018-01-13 16:59:11 · 438 阅读 · 0 评论 -
python字符串格式输出
s = "hello"print(s.capitalize()) # Capitalize a string; prints "Hello"print(s.upper()) # Convert a string to uppercase; prints "HELLO"print(s.rjust(7)) # Right-justify a string, padding原创 2018-02-01 23:01:11 · 505 阅读 · 0 评论 -
python字典函数values(),keys(),items()的用法与区别
三个函数都是查看字典中元素的函数,返回值都为一个list>>> dict = { 1 : 2, 'a' : 'b', 'hello' : 'world' } >>> dict.values() ['b', 2, 'world'] >>> dict.keys() ['a', 1, 'hello'] >>> dict.items() [('a', 'b'), (1, 2),原创 2018-01-20 23:09:02 · 12833 阅读 · 0 评论