随笔分类 - Python学习
摘要:如果要变成dict形式,可以使用以下 参考来源:https://stackoverflow.com/questions/613183/how do i sort a dictionary by value
阅读全文
摘要:原文来源:http://pbpython.com/pandas list dict.html 介绍 每当我使用pandas进行分析时,我的第一个目标是使用众多可用选项中的一个将数据导入Pandas的DataFrame 。 对于绝大多数情况下,我使用的 read_excel , read_csv 或
阅读全文
摘要:良好的代码风格体现出自己的专业,良好的代码风格,方便同事之间协作。 下面举例讲讲自己在代码中不符合python风格的一些情况,方便自己写出优雅的代码。 段落之间空两行 很长的参数用括号连接但是不要超过右侧长度,78,81个字符? 逗号之后加空格 加减符合左右加空格 代码风格其实很难界定,谷歌的pyt
阅读全文
摘要:运行 pip3 install upgrade pip 发生错误: 将以下代码: 修改为:
阅读全文
摘要:from flask import Flask from flask_cors import CORS app = Flask(__name__) CORS(app) @app.route("/") def helloWorld(): return "Hello, cross-origin-worl
阅读全文
摘要:jupyter notebook快捷键的使用
阅读全文
摘要:```
########
>>>[3] in [1,2,3,4]
False
>>>3 in [1,2,3,4]
True ########
x = (y = z + 1) 在Python中是非法的。
x = y = z + 1 这种赋值方式可称为 连续赋值、批量赋值、多元赋值、多变量赋值等。 ########
模拟 sorted的函数 def Sorted(v):
t = v[::...
阅读全文
摘要:来源 https://leetcode cn.com/problems/intersection of two arrays/ 题目描述 给定两个数组,写一个函数来计算它们的交集。 例子: 给定 num1= [1, 2, 2, 1], nums2 = [2, 2], 返回 [2]. 提示: 每个在结
阅读全文
摘要:题目 有一个长度为n序列,移除掉里面的重复元素,对于每个相同的元素保留最后出现的那个。 比方说: [1,8,7,3,8,3,1] 返回: [7,8,3,1] 算法实现 方法一: 方法二:
阅读全文
摘要:对于一个DataFrame A,A.loc[k]是读取A中index为k的那一行。A.iloc[k]是读取A中的第k行。
阅读全文
摘要:题目 若 a = (1, 2, 3),下列哪些操作是合法的? A a[1: 1] B a 3 C a[2] = 4 D list(a) 题解 答案:A B D
阅读全文
摘要:在python3下学习yield用法。 程序如下: 程序报错 错误原因 python 3.x中 generator(有yield关键字的函数则会被识别为generator函数)中的next变为__next__了,next是python 3.x以前版本中的方法。
阅读全文
摘要:安装xml库发生报错 尝试安装lxml进行代替
阅读全文
摘要:The common approach to get a unique collection of items is to use a set. Sets are unordered collections of distinct objects. To create a set from any
阅读全文
摘要:loc 从特定的 gets rows (or columns) with particular labels from the index. iloc gets rows (or columns) at particular positions in the index (so it only ta
阅读全文
摘要:今天调试程序,发现了一个极为隐蔽的bug. True False关键字大小写写错了,然后半天没找出问题所在。
阅读全文

浙公网安备 33010602011771号