![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
执念0513
新手
展开
-
python 数字判断
Given a string s, write a method (function) that will return true if its a valid single integer or floating number or false if its not.Valid examples, should return true:isDigit("3")isDigit(" 3...原创 2018-07-16 23:16:49 · 4871 阅读 · 0 评论 -
Python 字符替换
python中对字符串中的字符进行替换,首先想到的是str.replace()这对单个及少量字符的替换是比较方便的。例如,将所有的‘5’,‘0’,‘1’全部替换为‘S’,'O','I':>>> x= "W0W! 1'm 5o good!">>> x.replace('0','O').replace('1','I').replace('5...原创 2018-07-17 11:36:05 · 2099 阅读 · 2 评论 -
python 格式化字符串 str.format()
Task:Given a number, 3 for example, return a string with a murmur: "1 sheep...2 sheep...3 sheep..."Note:You will always receive a positive integer.可以直接用for和字符串拼接 ,不过需要先将range(1,n+1)字符串化,否则st...原创 2018-07-17 15:14:37 · 583 阅读 · 0 评论 -
python hello world
学习大多数的编程语言时,基本上都绕不开 hello world那么python的hello world呢,刚刚在codewars上看到了几个。切片def greet(): return 'dlrow olleh'[::-1]def greet(): return 'The most beautiful hello world'[19:] 编码greet...原创 2018-07-17 18:10:09 · 1124 阅读 · 0 评论 -
python set的应用
You are given two sorted arrays that contain only integers. Your task is to find a way to merge them into a single one, sorted inascending order. Complete the function mergeArrays(arr1, arr2), where ...原创 2018-07-24 10:13:41 · 707 阅读 · 0 评论 -
python 类的初识
Python作为高级语言,也是一门面向对象的语言。面向对象实现的基础就是类(Class)。今天来看一下python中类是如何创建的。如果有接触过面向对象,例如Java,那么对以下概念的理解应该不是很难。关于类的简介类(Class): 用来描述具有相同的属性和方法的对象的集合。它定义了该集合中每个对象所共有的属性和方法。它是一种抽象的概念。 类变量:类变量在整个实例化的对象中是公用的...原创 2018-07-19 14:20:39 · 296 阅读 · 0 评论 -
re 高级字符串处理工具
Description: Replace all vowel to exclamation mark in the sentence. aeiouAEIOU is vowel.Examples replace("Hi!") === "H!!" replace("!Hi! Hi!") === "!H!! H!!" replace("aeiou") === "!!!!!"原创 2018-07-15 19:04:44 · 376 阅读 · 1 评论 -
Python join()
一下是*/Python27/Lib/string.py中关于join的定义 join() 方法用于将序列中的元素以指定的字符连接生成一个新的字符串。def join(words, sep = ' '): #默认seq为一个空格 """join(list [,sep]) -> string #返回值为string Return a string composed of the...原创 2018-07-15 23:16:00 · 2367 阅读 · 0 评论