python函数注释,参数后面加冒号:,函数后面的箭头→是什么?

函数注释示例: def f(ham: 42, eggs: int = 'spam') -> "Nothing to see here": print("函数注释", f.__annotations__) print("参数值打印", ham, eggs) print(type(ham),type(eggs)) f("www") 返回信息: 函数注释 {'ham':...
分类: 其他 发布时间: 10-22 23:27 阅读次数: 0

python标准库OS和SYS

sys sys.path 列表 导入搜索的路径 import pprint pprint.pprint(sys.path) sys.path.append("F:\LXZ") sys.argv 是个参数列表 sys.exit([arg]) 参数整数或者字符串 0成功 字符串一般是错误信息的 sys.modules 字典 载入的模块 sys.platform 字符串...
分类: 其他 发布时间: 10-22 23:27 阅读次数: 0

python测试和两个小工具

测试 先测试后编码 ---->测试驱动 对程序的各部分 建立测试----> 单元测试 1.支出需要的新特性,编写一个测试程序 2.编写特性概要代码 3.为特性的概要编写虚设代码 4.重写代码 #Test_area.py from area import rect_area height = 3 width = 4 correct_answer = 12 answer = rect_a...
分类: 其他 发布时间: 10-22 23:26 阅读次数: 0

python pillow 基础

pillow python imaging library 是python生态中最有名的图片处理相关库 pip install pillow 一些基础操作 In [6]: os.listdir() Out[6]: ['book.jpg', 'hy.gif'] In [7]: from PIL import Image In [8]: im = Image.open('book.jpg') ...
分类: 其他 发布时间: 10-22 23:26 阅读次数: 0

itsdangerous token生成

发送激活邮件、链接 激活连接中,需要包含用户的身份信息 http://127.0.0.1/user/activate/3 id为3的用户激活 但这样发,很不安全 ,需要把用户的身份信息进行加密 pip install itsdangerous from itsdangerous import TimedJSONWebSignatureSerializer as Seria import t...
分类: 其他 发布时间: 10-22 23:26 阅读次数: 0

[LeetCode] 300. Longest Increasing Subsequence

题:https://leetcode.com/problems/longest-increasing-subsequence/description/ 题目 Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101...
分类: 其他 发布时间: 10-22 23:24 阅读次数: 0

[LeetCode] 583. Delete Operation for Two Strings

题:https://leetcode.com/problems/delete-operation-for-two-strings/description/ 题目 Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in e...
分类: 其他 发布时间: 10-22 23:24 阅读次数: 0

[编程之美] 3.1 字符串循环移位包含

题目 s1 = AABCD, s2 = CDAA Return : true 给定两个字符串 s1 和 s2,要求判定 s2 是否能够被 s1 做循环移位得到的字符串包含。 思路 以S1 = ABCD 为例,对其循环移位的后果为: ABCD -> BCDA -> CDAB -> DABC -> ABCD S1S1 = ABCDABCD 看出对S1做循环移位所得到的字符串都将...
分类: 其他 发布时间: 10-22 23:24 阅读次数: 0

[编程之美] 2.17 字符串循环移位

题目 将字符串向右循环移动 k 位 s = "abcd123" k = 3 Return "123abcd" 思路 方法一 翻转法 将子串 s[0:str.length() - k)] 翻转,子串s[str.length() - k,str.length()] 翻转。然后将整个字符翻转可以到最终结果。 eg: 将 abcd123 中的 abcd 和 123 单独翻转,得到 dcba321,然后对...
分类: 其他 发布时间: 10-22 23:23 阅读次数: 0

[LeetCode] 785. Is Graph Bipartite?

题:https://leetcode.com/problems/is-graph-bipartite/description/ 题目 Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipartite if we can split it’s set of n...
分类: 其他 发布时间: 10-22 23:22 阅读次数: 0

[LeetCode] 207. Course Schedule

题:https://leetcode.com/problems/course-schedule/description/ 题目 There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prerequisites, for example to take course ...
分类: 其他 发布时间: 10-22 23:22 阅读次数: 0

[LeetCode] 684. Redundant Connection

题:https://leetcode.com/problems/redundant-connection/description/ 题目 In this problem, a tree is an undirected graph that is connected and has no cycles. The given input is a graph that started as a tr...
分类: 其他 发布时间: 10-22 23:22 阅读次数: 0

[LeetCode] 345. Reverse Vowels of a String

题:https://leetcode.com/problems/reverse-vowels-of-a-string/description/ 题目 Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "hol...
分类: 其他 发布时间: 10-22 23:21 阅读次数: 0

[LeetCode] 680. Valid Palindrome II

题:https://leetcode.com/problems/valid-palindrome-ii/description/ 题目 Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Input: "aba...
分类: 其他 发布时间: 10-22 23:21 阅读次数: 0

[LeetCode] 451. Sort Characters By Frequency

题:https://leetcode.com/problems/sort-characters-by-frequency/description/ 题目 Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" ...
分类: 其他 发布时间: 10-22 23:21 阅读次数: 0

golang中Any类型使用及空接口中类型查询

golang中Any类型使用及空接口中类型查询
分类: 编程语言 发布时间: 10-22 23:21 阅读次数: 0

Object类中的常用方法

Object类简介,以及一些常用方法的使用
分类: 编程语言 发布时间: 10-22 23:21 阅读次数: 0

Javascript-数组与对象的区别

学习javascript的时候,我曾经一度搞不清楚”数组”(array)和”对象”(object)的根本区别在哪里,两者都可以用来表示数据的集合。
分类: 其他 发布时间: 10-22 23:20 阅读次数: 0

JavaScript-内置对象(1)

什么是对象?JavaScript 中的所有事物都是对象,如:字符串、数值、数组、函数等,每个对象带有属性和方法。
分类: 其他 发布时间: 10-22 23:20 阅读次数: 0

JavaScript-截取字符串

引言在js中字符串截取函数有常用的三个slice()、substring()、substr()函数,同时还有一些方法如split() 、Join() 、indexOf()可以对字符串进行操作,来获得截取我们想要的字符串
分类: 其他 发布时间: 10-22 23:20 阅读次数: 0