
Python基础
zhourunan123
这个作者很懒,什么都没留下…
展开
-
Python----matplotlib画图
Jupyter在用matplotlib画图的时候会产生图片不显示在页面中解决方法:%matplotlib inlineimport matplotlib.pyplot as pltplt.plot()plt.show()原创 2018-04-21 17:37:27 · 230 阅读 · 0 评论 -
Anaconda 安装gensim
镜像安装gensim原创 2018-05-25 21:36:34 · 7971 阅读 · 6 评论 -
Python爬虫----正则表达式符号与方法
常用符号:常用方法:原创 2018-05-17 23:15:46 · 260 阅读 · 0 评论 -
Python-----numpy函数库基础
1. 安装numpy库:pip install numpy 2. 将numpy函数库中的所有模块引入:from numpy import *3. 构造一个4*4的随机数组:randArray = random.rand(4,4)print(randArray)4.mat()函数:将数组转化为矩阵:randMat = mat(random.rand(4,4))print(randMat)5. ...原创 2018-04-23 21:24:30 · 988 阅读 · 0 评论 -
python----判断结构
print(8 == 8)print(8 != 8)原创 2018-04-19 22:53:55 · 481 阅读 · 0 评论 -
python----List操作
list1 = []list2 = []list1.append('a')list1.append('b')list1.append('c')print(list1)list2.append(1.0)list2.append(2.0)list2.append(3.0)list2.append(4.0)list2.append(5.0)print(list2)a = list...原创 2018-04-19 22:44:29 · 144 阅读 · 0 评论 -
Python----List
months = []print(type(months))months.append(1)months.append('Ja')months.append("Fe")print(months)原创 2018-04-19 22:42:30 · 167 阅读 · 0 评论 -
Python----类型转换
str_eight = str(8)print(type(str_eight))int_eight = int(str_eight) #转换成int型print(type(int_eight))原创 2018-04-19 22:39:58 · 171 阅读 · 0 评论 -
Python----查看类型
str_test = 'China'int_test = 123float_test = 122.5print(type(str_test))print(type(int_test))print(type(float_test))原创 2018-04-19 22:37:13 · 1444 阅读 · 0 评论 -
Python----函数基础
def printHello(): #printHello函数名 ()无参数 print('hello python')# 运行函数,直接调函数名printHello()def add(a,b): #带有参数 return(a+b)print(add(1,2))def printNum(): for i in range(0,10): print(i)...原创 2018-04-19 22:34:11 · 122 阅读 · 0 评论 -
Python文件处理----写操作
f = open("F:\python2.txt","w")f.write('123456')f.write('\n') #换行f.write('45678')f.close()原创 2018-04-19 21:56:34 · 160 阅读 · 0 评论 -
Python文件处理----读取一个文件
f = open("F:\python.txt","r") #路径g = f.read()print(g)f.close()原创 2018-04-19 21:47:19 · 680 阅读 · 0 评论 -
Python----循环结构
cities = ['AC','AD','AE']for city in cities: print(city)i = 0while i < 3: i = i+1 print(i)for i in range(10): print(i)cities = [[1,2,3,4],['a','b','c']]print (list)for city in ...原创 2018-04-19 22:51:11 · 186 阅读 · 0 评论 -
Python----字典
dic = {}print(type(dic))dic["a"] = 1dic["b"] = 2print(dic)dic = {"a":1,"b":2}print(dic)原创 2018-04-19 22:54:53 · 118 阅读 · 0 评论 -
Python----文件处理
weather_data = [] f = open("F:\weather.csv","r")data = f.read()rows = data.split('\n')print(rows) #切分1for row in rows: split_row = row.split(",") weather_data.append(split_row)print(weath...原创 2018-04-20 14:42:37 · 188 阅读 · 0 评论 -
Python----anaconda
anaconda prompt:>> conda list (查看已经装好的库)>>conda install 库名(安装库)>>conda update 库名(更新库)jupyter notebook:注释:Ctrl+/运行:Ctrl+Enter或Shift+Enter...原创 2018-04-20 14:51:56 · 152 阅读 · 0 评论 -
Python----导入文件报错
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \uXimport pandas as pdunrate = pd.read_csv("F:\unrate.csv")解决方法:文件名中的\u开始的字符被编译器认为是八进制import pandas as...原创 2018-04-21 16:58:11 · 741 阅读 · 0 评论 -
Anaconda ---报错
ImportError: No module named 'sklearn.model_selection'原因: sklearn库版本太低,升级为高版本方法1:cmd输入:conda update scikit-learn:方法2:方法1:update的速度超级慢进行如下操作:cmd输入1:conda config --add channels https://mirrors.tuna.ts...原创 2018-05-27 11:18:00 · 423 阅读 · 0 评论