
python-基础
annalittlezhou
前进路上的伪码农一枚
展开
-
多维列表排序、文件夹遍历、python列表字典csv读取
多维列表排序:先根据第一列排序,然而第二列,然后第三列import operatoralist=[[],[],[],[]]alist.sort(key=operator.itemgetter(0,1,2))遍历文件夹下的文件import os path = "D:/Python34/news" #文件夹目录 files= os.listdir(path) #得...原创 2017-11-20 23:29:07 · 1067 阅读 · 0 评论 -
MongoDB与python连接及读取信息
# -*- coding: utf-8 -*-__author__ = 'zww'import pprintfrom pymongo import MongoClientfrom bson import json_util as jsonbimport jsonimport csvclient = MongoClient('localhost', 27017)db = clie...原创 2018-03-23 16:22:52 · 2547 阅读 · 0 评论 -
leetcode in python 121
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), des...原创 2018-03-31 00:10:34 · 523 阅读 · 0 评论 -
leetcode in python 680
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.Example 1:Input: "aba"Output: TrueExample 2:Input: "abca"Output: TrueExplanation: You c...原创 2018-03-31 00:31:28 · 417 阅读 · 0 评论 -
leetcode in python 543
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath between any two nodes in a tree. This path may or may no...原创 2018-03-28 23:18:49 · 337 阅读 · 0 评论 -
leetcode in python 125
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 palindrome."race a car" is not a palindro...原创 2018-03-28 23:23:49 · 247 阅读 · 0 评论