- 博客(9)
- 收藏
- 关注
原创 检查出一个文件夹下所有文件和文件夹,并把最后修改日期为今天一天之前的删掉
#coding=UTF-8 import os.path import time import shutil import datetime if __name__ == '__main__': ttime = time.strftime("%Y-%m-%d", time.localtime()) ytime = datetime.datetime.strptime(
2017-07-27 13:33:47
1457
转载 python练习实例14,题目:将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。
def reduceNum(n): print '{}='.format(n) if not isinstance(n, int) or n 0: print '请输入一个正确的数字!' elif n in [1]: print '{}'.format(n) while n not in [1]: for i in xrange(
2017-07-12 11:03:21
2059
转载 14. Longest Common Prefix
class Solution(object): def longestCommonPrefix(self, strs): if len(strs)==0: return "" result="" s_len=len(strs[0]) for l in strs:
2017-06-26 15:50:29
173
原创 13. Roman to Integer
class Solution(object): def num(self,x): if x=='I': return 1 if x=='V': return 5 if x=='X': return 10 if x=='L':
2017-06-26 11:46:34
155
原创 9. Palindrome Number
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ y=list(str(x)) l=len(y) sign=1 for i i
2017-06-26 10:16:00
136
转载 Python学习:正则表达式
#!/usr/bin/python import re line = "Cats are smarter than dogs" matchObj = re.match(r'(.*) are (.*?) (.*) (.*)', line, re.M|re.I) if matchObj: print "matchObj.group() : ", matchObj.group()
2017-06-24 15:01:26
222
原创 2.reverse
ME: class Solution(object): def reverse(self,x): answer = 0 sign = 1 if x > 0 else -1 x = abs(x) if x==0: return 0
2017-06-24 13:53:23
238
原创 1.twoSum
ME: class Solution(object): def twoSum(self, nums, target): for i in range(len(nums)): for j in range(i+1,len(nums)): t = nums[i]+nums[j]
2017-06-24 13:50:22
179
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人