![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
BishopTylaor
这个作者很懒,什么都没留下…
展开
-
通过pip安装pytorch超时问题解决
前言这篇文章只记录通过pip安装pytorch超时问题的解决方案。默认阅读者已经安装了Python2.7或者其他3.x的版本版本信息系统:macos-11.1pip:21.0.1python:3.8解决方案第一步:去官网查询合适的版本和命令第二步:>pip install torch torchvision torchaudioCollecting torch Downloading torch-1.7.1-cp38-none-macosx_10_9_x86_64.w原创 2021-02-22 10:42:40 · 2882 阅读 · 3 评论 -
LeetCode.28.Implement strStr()
原题链接:Implement strStr()题目内容: Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1: Input: haystack = “hello”, needle = “ll” Out...原创 2018-04-08 19:26:53 · 116 阅读 · 0 评论 -
Python.json.常见两个错误处理(Expecting , delimiter)(Invalid control character at)
ValueError: Invalid control character at: line 1 column 122(char 123)出现错误的原因是字符串中包含了回车符(\r)或者换行符(\n) 解决方案:转义json_data = json_data.replace('\r', '\\r').replace('\n', '\\n')使用关键字strict...原创 2018-04-09 16:49:23 · 44571 阅读 · 2 评论 -
LeetCode.7.Reverse Integer
原题链接:Reverse Integer题目内容: Given a 32-bit signed integer, reverse digits of an integer.Example 1: Input: 123 Output: 321Example 2: Input: -123 Output: -321Example 3: Input:...原创 2018-04-10 15:04:19 · 144 阅读 · 0 评论 -
LeetCode.8.String to Integer (atoi)
原题链接:String to Integer (atoi)题目内容: Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask your...原创 2018-04-10 16:45:05 · 123 阅读 · 0 评论 -
Python文件下载总结
1. Requests模块import requests print "download with requests"url = 'https://linux.linuxidc.com/linuxconf/download.php?file=Li9saW51eGZpbGVzL0xpbnV4JUI5JUFCJUM5JUU3LnBuZw==' r = requests.get(url) ...原创 2018-04-16 14:54:44 · 199 阅读 · 0 评论 -
Python.Sqlalchemy.使用OEM相关语句
新增数据user = User(name='a')session.add(user)user = User(name='b')session.add(user)user = User(name='a')session.add(user)user = User()session.add(user)session.commit()使用User表相关操作from sq...原创 2018-04-18 18:25:49 · 258 阅读 · 0 评论 -
LeetCode.88.Merge Sorted Array
原题链接:Merge Sorted Array题目内容: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n r...原创 2018-05-07 17:51:00 · 149 阅读 · 0 评论 -
LeetCode.19.Remove Nth Node From End of List
原题链接:Remove Nth Node From End of List题目内容: Given a linked list, remove the n-th node from the end of list and return its head.Example: Given linked list: 1->2->3->4->5, and n = 2....原创 2018-08-29 16:54:26 · 110 阅读 · 0 评论 -
LeetCode.206.Reverse Linked List
原题链接:Reverse Linked List题目内容: Reverse a singly linked list.Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL原创 2018-09-06 17:50:10 · 131 阅读 · 0 评论 -
python中去掉字符串中的\xa0、\t、\n等字符
\xa0是不间断空白符  我们通常所用的空格是 \x20,是在标准ASCII可见字符 0x20~0x7e 范围内。而 \xa0属于 latin1 (ISO/IEC_8859-1)中的扩展字符集字符,代表空白符nbsp(non-breaking space)。latin1 字符集向下兼容 ASCII ( 0x20~0x7e )。inputstring = u'\n ...原创 2019-01-19 15:08:28 · 7031 阅读 · 0 评论 -
python 判断字符串相似度
方法1import difflibdef get_equal_rate(str1, str2): return difflib.SequenceMatcher(None, str1, str2).quick_ratio()方法2import Levenshteindef get_equal_rate(str1, str2): return Levenshtein.ratio...原创 2019-01-19 15:27:16 · 14255 阅读 · 4 评论 -
Python 文件相关操作
内置函数文件读取通常我们在读取文件的时候,会用到read(), readline(), readlines()。read ()的方法是一次性把文件的内容以字符串的方式读到内存, 放到一个字符串变量中readlines()的方法是一次性读取所有内容, 并按行生成一个list因为read()和readlines()是一次性把文件加载到内存, 如果文件较大, 甚至比内存的大小还大, 内存就会爆...原创 2019-01-28 18:20:38 · 223 阅读 · 0 评论 -
LeetCode.66.Plus One
原题链接:Plus One题目内容:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 i...原创 2018-03-16 11:25:02 · 132 阅读 · 0 评论 -
LeetCode.283.Move Zeroes
原题链接:Move Zeroes题目内容:Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12]...原创 2018-03-19 19:04:46 · 128 阅读 · 0 评论 -
LeetCode.1.Two Sum
原题链接:Two Sum题目内容:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you ma...原创 2018-03-20 18:09:49 · 120 阅读 · 0 评论 -
Tornado 模板引擎转义语法
使用tornado的模板的时候,会遇到一些情况,,而不是简单地字符串的规则。tornado模板为了安全性,默认会全部转义。如果需要直接渲染html代码内容,那么有以下两种方法:1. {% raw message %}2.{% autoescape None %}{{ title }}{{ escape(title) }}原创 2018-02-02 10:10:50 · 654 阅读 · 0 评论 -
python基础学习
出处# _*_ coding: utf-8 _*_"""类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算"""#-- 寻求帮助: dir(obj) # 简单的列出对象obj所包含的方法名称,返回一个字符串列表 ...转载 2018-02-28 15:32:32 · 275 阅读 · 0 评论 -
LeetCode.14.Longest Common Prefix
原题链接:Longest Common Prefix题目内容: Write a function to find the longest common prefix string amongst an array of strings.找到字符列表中的最长前缀,注意[], [“”], [“a”, “a”]这样的例子Pythonclass Solution(object):...原创 2018-04-07 18:32:48 · 113 阅读 · 0 评论 -
LeetCode.38.Count and Say
原题链接:Count and Say题目内容: The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221 1 is read off as “one 1” or 11. 11 i...原创 2018-03-30 19:33:27 · 114 阅读 · 0 评论 -
LeetCode.125.Valid Palindrome
原题链接:Valid Palindrome 题目内容: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a pa...原创 2018-03-30 19:03:15 · 113 阅读 · 0 评论 -
LeetCode.242.Valid Anagram
原题链接:Valid Anagram题目内容: Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return fa...原创 2018-03-28 19:09:41 · 131 阅读 · 0 评论 -
LeetCode.387.First Unique Character in a String
原题链接:First Unique Character in a String题目内容: Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples: s = “leetcode” re...原创 2018-03-28 18:07:30 · 108 阅读 · 0 评论 -
LeetCode.344.Reverse String
原题链接:Reverse String题目内容: Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.Pythonclass Solution(object): def...原创 2018-03-28 16:44:56 · 125 阅读 · 0 评论 -
LeetCode.326.Power of Three
原题链接:Power of Three题目内容: Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion?Credits: Special thanks to @d...原创 2018-03-28 14:30:58 · 196 阅读 · 0 评论 -
LeetCode.204.Count Primes
原题链接:Count Primes题目内容: Description:Count the number of prime numbers less than a non-negative number, n.Credits: Special thanks to @mithmatt for adding this problem and creating all test cases...原创 2018-03-28 11:54:27 · 105 阅读 · 0 评论 -
LeetCode.412.Fizz Buzz
原题链接:Fizz Buzz题目内容:Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of f...原创 2018-03-23 17:46:31 · 140 阅读 · 0 评论 -
LeetCode.36.Valid Sudoku
原题链接:Valid Sudoku题目内容:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. A...原创 2018-03-23 17:19:53 · 140 阅读 · 0 评论 -
python UUID
转载自:http://www.cnblogs.com/dkblog/archive/2011/10/10/2205200.html资料: Python官方Doc:《20.15. uuid — UUID objects according to RFC 4122》 UUID的算法介绍:《A Universally Unique IDentifier (UUID) URN转载 2017-03-06 15:20:58 · 217 阅读 · 0 评论