自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(41)
  • 收藏
  • 关注

原创 ValueError: Object arrays cannot be loaded when allow_pickle=False 异常的多种处理方式

目前更新到最新的numpy版本后,使用 numpy.load() 可能会报错:ValueError: Object arrays cannot be loaded when allow_pickle=False这是因为numpy版本不向下兼容所导致的,更新之前的numpy版本中(比如:1.16.1 或者 1.16.2版本)的load函数为:numpy.load(path),而更新后的lo...

2019-12-17 20:19:22 12103

原创 【Codewars python 4kyu】:Total increasing or decreasing numbers up to a power of 10

问题描述:Let's defineincreasingnumbers as the numbers whose digits, read from left to right, are never less than the previous ones: 234559 is an example of increasing number.Conversely,decreasingn...

2019-09-08 15:45:42 479

原创 【Codewars python 3kyu】:Last digit of a huge number

问题描述:For a given list[x1, x2, x3, ..., xn]compute the last (decimal) digit ofx1 ^ (x2 ^ (x3 ^ (... ^ xn))).E. g.,last_digit([3, 4, 2]) == 1because3 ^ (4 ^ 2) = 3 ^ 16 = 43046721.Beware:...

2019-09-08 15:45:36 866

原创 【Codewars python 5kyu】:Last digit of a large number

问题描述:Define a function that takes in two non-negative integersaandband returns the last decimal digit ofa^b. Note thataandbmay be very large!For example, the last decimal digit of9^7is...

2019-09-08 15:45:30 428

原创 【Codewars python 4kyu】:Explosive Sum

问题描述:How many ways can you make the sum of a number?From wikipedia:https://en.wikipedia.org/wiki/Partition_(number_theory)#In number theory and combinatorics, a partition of a positive integer...

2019-09-08 15:45:25 858

原创 【Codewars python 6kyu】: Write Number in Expanded Form

问题描述:Write Number in Expanded FormYou will be given a number and you will need to return it as a string inExpanded Form. For example:expanded_form(12) # Should return '10 + 2'expanded_form(42...

2019-09-08 15:45:19 823

原创 【Codewars python 5kyu】: Pick peaks

问题描述:In this kata, you will write a function that returns the positions and the values of the "peaks" (or local maxima) of a numeric array.For example, the arrayarr = [0, 1, 2, 5, 1, 0]has a pea...

2019-09-08 15:45:11 404

原创 【Codewars C++ 3kyu】: Path Finder #3: the Alpinist

问题描述:TaskYou are at start location[0, 0]in mountain area of NxN and you canonlymove in one of the four cardinal directions (i.e. North, East, South, West). Return minimal number ofclimb round...

2019-09-08 15:45:06 564

原创 【Codewars python 4kyu】: Permutations

问题描述:In this kata you have to create all permutations of an input string and remove duplicates, if present. This means, you have to shuffle all letters from the input in all possible orders.Exampl...

2019-09-08 15:44:59 600

原创 【Codewars python 6kyu】: Valid Braces

问题描述:Write a function that takes a string of braces, and determines if the order of the braces is valid. It should returntrueif the string is valid, andfalseif it's invalid.This Kata is simila...

2019-09-08 15:44:52 293

原创 【Codewars python 4kyu】: Breadcrumb Generator

问题描述:Asbreadcrumb menùsare quite popular today, I won't digress much on explaining them, leaving the wiki link to do all the dirty work in my place.What might not be so trivial is instead to get...

2019-09-07 11:12:23 458

原创 【Codewars python 4kyu】: Hamming Numbers

问题描述:A *Hamming number* is a positive integer of the form 2i3j5k, for some non-negative integersi,j, andk.Write a function that computes thenth smallest Hamming number.Specifically:The fir...

2019-09-07 11:12:17 594

原创 【Codewars python 4kyu】: Range Extraction

问题描述:A format for expressing an ordered list of integers is to use a comma separated list of eitherindividual integers or a range of integers denoted by the starting integer separated from the en...

2019-09-07 11:12:10 406

原创 【Codewars python 4kyu】: Strings Mix

问题描述:Given two strings s1 and s2, we want to visualize how different the two strings are. We will only take into account thelowercaseletters (a to z). First let us count the frequency of eachlowe...

2019-09-07 11:12:00 337

原创 【Codewars python 4kyu】: Human readable duration format

问题描述:Your task in order to complete this Kata is to write a function which formats a duration, given as a number of seconds, in a human-friendly way.The function must accept a non-negative integer...

2019-09-07 11:11:47 329

原创 【Codewars python 5kyu】: String incrementer

问题描述:Your job is to write a function which increments a string, to create a new string.If the string already ends with a number, the number should be incremented by 1. If the string does not end ...

2019-09-07 11:11:41 391

原创 【Codewars python 6kyu】: Take a Number And Sum Its Digits Raised To The Consecutive Powers And ....¡E

问题描述:The number89is the first integer with more than one digit that fulfills the property partially introduced in the title of this kata. What's the use of saying "Eureka"? Because this sum gives ...

2019-09-07 11:11:35 674

原创 【Codewars python 5kyu】: Directions Reduction

问题描述:Once upon a time, on a way through the old wild west,…… a man was given directions to go from one point to another. The directions were "NORTH", "SOUTH", "WEST", "EAST". Clearly "NORTH" and "...

2019-09-07 11:11:29 361

原创 【Codewars python 5kyu】: Number of trailing zeros of N!

问题描述:Write a program that will calculate the number of trailing zeros in a factorial of a given number.N! = 1 * 2 * 3 * ... * NBe careful1000!has 2568 digits...For more info, see:http://mat...

2019-09-07 11:11:23 415

原创 【Codewars python 5kyu】: First non-repeating character

问题描述:Write a function namedfirst_non_repeating_letterthat takes a string input, and returns the first character that is not repeated anywhere in the string.For example, if given the input'stres...

2019-09-07 11:11:13 403

原创 【Codewars python 6kyu】: Does my number look big in this?

问题描述:ANarcissistic Numberis a number which is the sum of its own digits, each raised to the power of the number of digits in a given base. In this Kata, we will restrict ourselves to decimal (base...

2019-09-05 11:20:37 537

原创 【Codewars JavaScript 5kyu】: Scramblies

问题描述:Complete the functionscramble(str1, str2)that returnstrueif a portion ofstr1characters can be rearranged to matchstr2, otherwise returnsfalse.Notes:Only lower case letters will be u...

2019-09-05 11:20:30 464

原创 【Codewars python 5kyu】: Rot13

问题描述:ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.Create a function that takes ...

2019-09-05 11:20:23 318

原创 【Codewars python 6kyu】: Split Strings

问题描述:Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the fi...

2019-09-05 11:20:16 399

原创 【Codewars python 6kyu】: Build Tower

问题描述:Build TowerBuild Tower by the following given argument:number of floors(integer and always greater than 0).Tower block is represented as*Python: return alist; JavaScript: returns anA...

2019-09-05 11:20:08 630

原创 【Codewars python 7kyu】: Remove the minimum

问题描述:The museum of incredible dull thingsThe museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the most boring e...

2019-09-05 11:19:51 700

原创 【Codewars python 7kyu】: You're a square!

问题描述:A square of squaresYou like building blocks. You especially like building blocks that are squares. And what you even like more, is to arrange them into a square of square building blocks!Ho...

2019-09-05 11:19:43 1032

原创 【Codewars python 8kyu】: Multiply

问题描述:The code does not execute properly. Try to figure out why.代码实现:def multiply(a, b): return a * b

2019-09-05 11:19:34 250

原创 【Codewars python 7kyu】: List Filtering

问题描述:In this kata you will create a function that takes a list of non-negative integers and strings and returns a new list with the strings filtered out.Example:filter_list([1,2,'a','b']) == [1...

2019-09-05 11:19:24 326

原创 【Codewars python 7kyu】: Isograms

问题描述:An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the em...

2019-09-05 11:18:58 299

原创 【Codewars_python 7kyu】:Regex validate PIN code

问题描述:ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits.If the function is passed a valid PIN string, return true, else return...

2019-09-04 20:34:40 362

原创 python中的类方法、类属性以及单例设计模式

# 属性向上查找机制 :# 1、当用类名直接访问类属性时,会直接去类内查找该属性的名称 ,找到了就可以直接用# 2、当用对象名访问属性时,无论是类属性还是对象自己的属性,都会先在自己的存储空间内查找,有必要时向上查找 (不推荐使用对象名访问类属性)# 当是类属性时,如果不是赋值语句,会向上查找(先找自己内部存储空间,再找类内空间)# 当是类属性时,如果是赋值语句,会在对象存储...

2019-09-04 20:27:34 193

原创 python中的异常及异常的传递

'''异常 : 1、一些内置的异常类 基本上都是Exception的子类(派生出来的) 2、异常的传递 : 从产生异常的地方开始传递到调用异常的地方 如果一直没有处理异常 会一直传递到主函数 然后停止程序并报出异常信息 3、try: except: else: finally: 捕获异常并处理4、主动抛出异常 :比如输入密码时要求密码长度超...

2019-09-04 20:26:10 1233

原创 Python中的类(class)、属性、继承和方法

# 多态的三个例子: 1、x.count() str.count() 2、 1+2 'he'+'xianmin' 3、 repr(x) 无论x传什么都是原样# 类 : 将 首字母大写的单数 为类的名称# 创建实例时实例的存储空间 以及 实例外调用类内的属性 的 例子class MemberCounter: #创建一个类 !!...

2019-09-04 20:24:33 2149

原创 Python中的函数(def)及参数传递

#抽象 (函数)# 1、callable 判断一个对象是否可以被调用x = 1def y(): return Nonecallable(y) # y可以被调用callable(x) # x不可以被调用# 2、当函数没有return时 函数将默认返回None# 3、放在函数开头的字符串成为文档字符串 如下:def square(x): 'my n...

2019-09-04 20:21:37 13617 1

原创 python学习小记

# print 的一些使用# 1、逗号分隔打印多个print('asd',',',1,'vsv')# 2、加号 进行字符串相加print('asd'+',',1,'vsv')# 3、sep = "-" 使用制定的字符串进行链接字符print('my','name','is','hexianmin',sep='-')# 4、指定打印结束的字符 end = ''...

2019-09-04 20:19:27 150

原创 Python中的赋值、浅拷贝、深拷贝的区别和联系

# 1、赋值(注意空赋值改变地址指向) 2、浅拷贝 3、深拷贝#直接赋值(除了用空去赋值) : x、y指向同一个地址空间的值,所以后面对x还是y进行修改x、y两者都会变x = {}y = x # x为原件 y为附件x['value'] = 24y['value'] = 26x['value'] = 25print(id(x),id(y))...

2019-09-04 20:16:08 122

原创 Python中的字典(dict)及其基本操作

#字典的基本操作 1、(字典 '键' 和 '值' 对称为 '项') 2、空字典:{} 3、字典中键必须是独一无二的 字典中的值无须如此#创建字典的三种方法: #1、dict((元组对))term = [('name',['hexianmin']),('age',21)] #一个元组对为一项 这样也可以:term = (('name','hexianmin'),...

2019-09-04 20:14:18 1097

原创 Python中的字符串(str)及其基本操作

#字符串的基本操作#1、格式控制 与c语言基本一样 : %d %c %f %s %.2f 在匹配时 '%' 相当于 c语言中 ',' 的作用str = 'hello %c,%d name is %s'm_tuple = tuple(('w',1,'hexianmin'))str % m_tuple# 2、模板字符串 $后面的内容要紧跟着$ ...

2019-09-04 20:12:24 948

原创 Python中的列表(list)和元组(tuple)

一、列表(list)#list的一系列操作和知识点#1、定义 list() 将字符串分解成一个一个单个字符成list 。但是, [ , , ] 将每一部分""当作一个list中的元素。 请区别!_mylist1 = ["vv","ds","fs"]*3 #第一种直接赋值_mylist2 = list("my""name"*2) #list两种方法都可以使用乘法#2、list...

2019-09-04 20:06:16 357

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除