随笔分类 -  python

上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 48 下一页
摘要:def hb(list1,list2): result = [] while list1 and list2: if list1[0] >> [1, 2, 3, 4, 5, 7, 8, 9, 11, 13, 20] 阅读全文
posted @ 2019-03-04 11:47 anobscureretreat 阅读(1748) 评论(0) 推荐(0)
摘要:class Solution(object): def hb(self,list1,list2): result = [] while list1 and list2: if list1[0] < list2[0]: result.append(list1[0]) ... 阅读全文
posted @ 2019-03-04 11:46 anobscureretreat 阅读(132) 评论(0) 推荐(0)
摘要:class Solution(object): def addTwoNumbers(self, l1, l2): l3 = ListNode(0) current = l3 carry = 0 while l1 or l2: # 1,1 | None,1 | 1,None # Pad 0 if N... 阅读全文
posted @ 2019-03-04 10:41 anobscureretreat 阅读(137) 评论(0) 推荐(0)
摘要:class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ dictionary = dict() ... 阅读全文
posted @ 2019-03-04 10:39 anobscureretreat 阅读(151) 评论(0) 推荐(0)
摘要:class Solution(object): def lengthOfLongestSubstring(self, s): d = "" f = "" for i in range(len(s)): if s[i] not in f: f += s[i] ... 阅读全文
posted @ 2019-03-04 10:32 anobscureretreat 阅读(141) 评论(0) 推荐(0)
摘要:>>>seasons = ['Spring', 'Summer', 'Fall', 'Winter'] >>> list(enumerate(seasons)) [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')] >>> list(enumerate(seasons, start=1)) # 下标从 1 开始 [(... 阅读全文
posted @ 2019-03-03 12:15 anobscureretreat 阅读(116) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2019-03-03 01:29 anobscureretreat 阅读(176) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2019-03-03 00:35 anobscureretreat 阅读(213) 评论(0) 推荐(0)
摘要:target: numbers = ['2', '4', '1', '3'] 排序: 从小到大排序: 从大到小排序: 参考: https://blog.csdn.net/liao392781/article/details/80592761 阅读全文
posted @ 2019-03-03 00:20 anobscureretreat 阅读(560) 评论(0) 推荐(0)
摘要:列表转字符串 字符串转列表 输出 阅读全文
posted @ 2019-03-03 00:17 anobscureretreat 阅读(306) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2019-03-03 00:14 anobscureretreat 阅读(172) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2019-03-03 00:13 anobscureretreat 阅读(275) 评论(0) 推荐(0)
摘要:对需要 str->unicode 的代码,可以在前边写上 import sys reload(sys) sys.setdefaultencoding(‘utf8′) 把 str 编码由 ascii 改为 utf8 (或 gb18030) 参考: https://blog.csdn.net/mindm 阅读全文
posted @ 2019-02-27 16:59 anobscureretreat 阅读(205) 评论(0) 推荐(0)
摘要:sudo apt-get install python-pip 阅读全文
posted @ 2019-02-26 17:04 anobscureretreat 阅读(267) 评论(0) 推荐(0)
摘要:class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ left, right = 0, len(nums) - ... 阅读全文
posted @ 2019-02-25 19:32 anobscureretreat 阅读(180) 评论(0) 推荐(0)
摘要:Python拿来做爬虫的确很不错,但是字符串的编码的确是稍不留神就是一个坑,GBK编码和Unicode编码的转化出现问题也是很多的,今天在解析网页数据的时候出现上述错误,解决方案如下: one_str.encode("GBK","ignore") 由于在windows下的cmd中输出网页数据,加入上 阅读全文
posted @ 2019-02-23 13:32 anobscureretreat 阅读(1538) 评论(0) 推荐(0)
摘要:js中 ret = 1 == 1 ? 'true' : 'false' ret = 1 == 1 ? 'true' : 'false' ret = 1 == 1 ? 'true' : 'false' ret = 1 == 1 ? 'tr 阅读全文
posted @ 2019-02-23 13:30 anobscureretreat 阅读(353) 评论(0) 推荐(0)
摘要:UnicodeEncodeError: 'gbk' codec can't encode character '\u25aa' in position 15: illegal multibyte sequence 阅读全文
posted @ 2019-02-23 13:12 anobscureretreat 阅读(864) 评论(1) 推荐(0)
摘要:JSON (JavaScript Object Notation) 是一种轻量级的数据交换格式。它基于ECMAScript的一个子集。 1、json.dumps()和json.loads()是json格式处理函数(可以这么理解,json是字符串) 在json的编解码过程中,python 的原始类型与 阅读全文
posted @ 2019-02-17 23:38 anobscureretreat 阅读(377) 评论(0) 推荐(0)
摘要:报错 改为如下,加入c参数: 输出 阅读全文
posted @ 2019-02-17 23:22 anobscureretreat 阅读(483) 评论(0) 推荐(0)

上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 48 下一页