# -*- coding: utf-8 -*-
# @Time : 2019/7/11 10:34
# @Author : 奥利波德
# @FileName: getPath.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/qq_44265507
import tkinter as tk
from tkinter import filedialog
import pandas
import numpy as np
import matplotlib.pyplot as plt
file_list = []
def show_windows():
root = tk.Tk()
root.title("getPath")
frm = tk.Frame(root)
frm.grid(padx='20', pady='30')
btn = tk.Button(frm, text='上传文件', command=upload_files)
btn1 = tk.Button(frm, text='展示图像', command=showFigure_Var)
btn.grid(row=0, column=0, ipadx='3', ipady='3', padx='10', pady='20')
btn1.grid(row=1, column=1, ipadx='3', ipady='5', padx='10', pady='30')
global text1
text1 = tk.Text(frm, width='55', height='15')
text1.grid(row=0, column=1)
root.mainloop()
def upload_files():
selectFiles = tk.filedialog.askopenfilenames(
title='可选择1个或多个文件') # askopenfilename 1次上传1个;askopenfilenames 1次上传多个
for selectFile in selectFiles:
text1.insert(tk.END, selectFile + '\n') # 更新text中内容
global file_list
file_list.append(selectFile)
text1.update()
def read():
paths = file_list
y = [[], [], []]
for a in range(len(paths)):
file1 = pandas.read_csv(paths[a])
for i in range(file1.shape[1]):
for j in range(file1.shape[0]):
y[a].append(file1[str(i)][j])
return y
def showFigure_Var():
windows = tk.Tk()
# windows.attributes("-alpha", 0.8)
windows.title('Plt Tk Np (By Cjc~)')
windows.geometry('600x400')
windows.geometry('+10+20')
# windows.wm_attributes('-topmost', 1)
butt1 = tk.Button(windows, text='show me first figure', command=show_first)
butt1.place(x=100, y=20)
butt2 = tk.Button(windows, text='show me Second figure', command=show_second).place(x=100, y=60)
butt3 = tk.Button(windows, text='show me Third figure', command=show_third).place(x=100, y=100)
windows.mainloop()
def plt_show(flag):
# 获取x,y
if flag == 1:
y = read()[0]
elif flag == 2:
y = read()[1]
elif flag == 3:
y = read()[2]
else:
print("in flag error")
x_len = len(y)
x = np.arange(0, x_len)
# 生成figure
plt.plot(x, y)
# 坐标轴标记
plt.xlabel('I am X')
plt.ylabel('I am Y')
# 设置刻度值
# new_ticks = np.linspace(0, 250, 11)
# new_ticks_y = np.linspace(-25, 5, 7)
# plt.yticks(new_ticks_y)
# plt.xticks(new_ticks)
# 设置隐藏X,Y轴
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
# 设置脊梁对应X,Y轴
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
# 设置X,Y轴交汇点
# if flag == 1:
# ax.spines['bottom'].set_position(('data', 25))
# ax.spines['left'].set_position(('data', 0))
# else:
# ax.spines['bottom'].set_position(('data', 0))
# ax.spines['left'].set_position(('data', 0))
# show
plt.show()
def show_all():
print("eee")
def show_first():
plt_show(1)
def show_second():
plt_show(2)
def show_third():
plt_show(3)
if __name__ == '__main__':
show_windows()
#include
//定义顺序表的最大长度
#define MAXSIZE 20
typedef int ElemType;
//定义一个结构体变量 即顺序表
typedef struct {
ElemType data[MAXSIZE];
int length;
}SqList;
// 表示函数状态代码
typedef int Status;
//传入一个列表 获取第i个元素的值给 e
Status GetElem(SqList L, int i, ElemType *e)
{
/*
1.列表为空、i小于1即不存在、i取值超过数组长度
2.即成功返回1 否 返回0
*/
if (L.length == 0 || i<1 || i>L.length)
return 0;
*e = L.data[i - 1];
return 1;
}
//插入元素
Status Listinsert(SqList *L, int i, ElemType e)
{
/*
cjc:
传入一个列表、要插入的位置,要插入的值
1.判断插入是否合理有效
2.判断是不是最末尾的结点,如果是直接尾随;
3.判断插入后会不会溢出
4.判断列表是否为空
5.。。。
*/
/*
t:
1.如果插入位置不合理,抛出异常
2.如果线性表长度大于等于数组长度,则抛出异常或动态增加容量
3.从最后一个元素开始向前遍历到第i个位置,分别将它们都向后移动一个位置
4.将要插入元素填入位置i处
5.表长加1
*/
int k;
if (L -> length == MAXSIZE)
{
return 0;
}
if (i < 1 || i - 1 > L -> length)
{
return 0;
}
if (i <= L -> length)
{
for (k = L->length-1;k>=i-1;k--)
{
L->data[k - 1] = L->data[k];
}
}
L->data[i - 1] = e;
L->length++;
return 1;
}
Status ListDelete(SqList *L, int i, ElemType *e)
{
/*
1.如果删除位置不合理,则抛出异常
2.取出删除元素
3.从删除元素位置开始遍历到最后一个元素位置,分别将它们都向前移动一个位置
4.表长减1
*/
if (i<1||i>L->length||L->length==0)
{
return 0;
}
*e = L->data[i - 1];
if (i<L->length)
{
for (i; i < L->length; i++)
{
L->data[i - 1] = L->data[i];
}
}
L->length--;
return 1;
}
#include
#include
#define MAXSIZE 20
typedef int ElemType;
typedef struct Node
{
ElemType data;
struct Node *next;
}Node;
typedef struct Node *LinkList;
int GetElem(LinkList L, int i, ElemType *e)
{
/**
1.p不为空,要得到第i个数,即从第一个数开始查询到第i个数
2.当表为空时,或者出界时报错
3.赋值
**/
int k=1;
LinkList p = L->next;
while (p&&k<i)
{
p = p->next;
k++;
}
if (!p||k>i)
{
return 0;
}
*e = p->data;
return 0;
}
int ListInsert(LinkList *L, int i, ElemType *e)
{
LinkList n,p = *L;
int k = 1;
if (i<1)
{
return 0;
};
while (p&&k<i)
{
p = p->next;
k++;
};
if (!p||k>i)
{
return 0;
};
n = (LinkList)malloc(sizeof(Node));
n->data = *e;
n->next = p->next;
p->next = n;
return 1;
}
int ListDelete(LinkList *L, int i, ElemType *e)
{
int k = 1;
LinkList q,p = *L;
while (p->next&&k<i)
{
p = p->next;
k++;
}
if (!(p->next)||k>i-1)
{
return 0;
}
q = p->next;
//q->next = p->next->next;
//*e = p->next->data;
p->next = q->next;
*e = q->data;
free(q);
return 1;
}
豆瓣:https://pypi.doubanio.com/simple/
阿里:http://mirrors.aliyun.com/pypi/simple/
清华:https://pypi.tuna.tsinghua.edu.cn/simple/
例如我要下载第三方库词云wordcloud,就可以这样CMD,极快!
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ wordcloud
还算充实、不算浪费、勉强进步、再接再厉