随笔分类 - python
摘要:def hb(list1,list2): result = [] while list1 and list2: if list1[0] >> [1, 2, 3, 4, 5, 7, 8, 9, 11, 13, 20]
        阅读全文
            
摘要:class Solution(object): def hb(self,list1,list2): result = [] while list1 and list2: if list1[0] < list2[0]: result.append(list1[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...
        阅读全文
            
摘要:class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ dictionary = dict() ...
        阅读全文
            
摘要:class Solution(object): def lengthOfLongestSubstring(self, s): d = "" f = "" for i in range(len(s)): if s[i] not in f: f += s[i] ...
        阅读全文
            
摘要:>>>seasons = ['Spring', 'Summer', 'Fall', 'Winter'] >>> list(enumerate(seasons)) [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')] >>> list(enumerate(seasons, start=1)) # 下标从 1 开始 [(...
        阅读全文
            
摘要:target: numbers = ['2', '4', '1', '3'] 排序: 从小到大排序: 从大到小排序: 参考: https://blog.csdn.net/liao392781/article/details/80592761
        阅读全文
            
                
    解决UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128
    
            
            
摘要:对需要 str->unicode 的代码,可以在前边写上 import sys reload(sys) sys.setdefaultencoding(‘utf8′) 把 str 编码由 ascii 改为 utf8 (或 gb18030) 参考: https://blog.csdn.net/mindm
        阅读全文
            
摘要:sudo apt-get install python-pip
        阅读全文
            
摘要:class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ left, right = 0, len(nums) - ...
        阅读全文
            
                
    解决UnicodeEncodeError: 'gbk' codec can't encode character u'\u25aa' in position 344 : illegal multiby
    
            
            
摘要:Python拿来做爬虫的确很不错,但是字符串的编码的确是稍不留神就是一个坑,GBK编码和Unicode编码的转化出现问题也是很多的,今天在解析网页数据的时候出现上述错误,解决方案如下: one_str.encode("GBK","ignore") 由于在windows下的cmd中输出网页数据,加入上
        阅读全文
            
摘要:js中 ret = 1 == 1 ? 'true' : 'false' ret = 1 == 1 ? 'true' : 'false' ret = 1 == 1 ? 'true' : 'false' ret = 1 == 1 ? 'tr
        阅读全文
            
摘要:UnicodeEncodeError: 'gbk' codec can't encode character '\u25aa' in position 15: illegal multibyte sequence
        阅读全文
            
摘要:JSON (JavaScript Object Notation) 是一种轻量级的数据交换格式。它基于ECMAScript的一个子集。 1、json.dumps()和json.loads()是json格式处理函数(可以这么理解,json是字符串) 在json的编解码过程中,python 的原始类型与
        阅读全文
            
摘要:报错 改为如下,加入c参数: 输出
        阅读全文
            
                    
                
浙公网安备 33010602011771号