随笔分类 -  Python

摘要:List comprehensions provide a concise way to create new lists, where each item is the result of an operation applied to each member of an existing lis 阅读全文
posted @ 2017-12-10 23:24 Zhentiw 阅读(290) 评论(0) 推荐(0) 编辑
摘要:isinstance("foo", str) isinstance(1, int) isinstance(4.0, float) 阅读全文
posted @ 2017-12-10 23:14 Zhentiw 阅读(164) 评论(0) 推荐(0) 编辑
摘要:For example you want to know what methods are available in Python for String, you can do : Output: Now for example, we want to see How to use 'swapcas 阅读全文
posted @ 2017-12-10 02:46 Zhentiw 阅读(224) 评论(0) 推荐(0) 编辑
摘要:Single quotes and double quotes can both be used to declare strings in Python. You can even use triple-double quotes! Learn when to use each in this l 阅读全文
posted @ 2017-12-09 23:05 Zhentiw 阅读(169) 评论(0) 推荐(0) 编辑
摘要:Python scripts can be executed by passing the script name to the python command or created as executable commands that can run stand-alone. You’ll lea 阅读全文
posted @ 2017-12-09 17:59 Zhentiw 阅读(1526) 评论(0) 推荐(0) 编辑
摘要:In this lesson, you will learn what mutable and immutable objects are, and the difference between them. This understanding will help you determine whe 阅读全文
posted @ 2017-12-09 17:53 Zhentiw 阅读(261) 评论(0) 推荐(0) 编辑
摘要:If you’ve used other programming languages, you may have learned that an empty object is not the same as an object that does not exist. In this lesson 阅读全文
posted @ 2017-12-09 17:49 Zhentiw 阅读(1443) 评论(0) 推荐(0) 编辑
摘要:Virtual Environments ensure that dependencies from one Python application don’t overwrite the dependencies of another application. In this lesson, you 阅读全文
posted @ 2017-12-09 17:41 Zhentiw 阅读(197) 评论(0) 推荐(0) 编辑
摘要:import time import urllib import bs4 import requests start_url = "https://en.wikipedia.org/wiki/Special:Random" target_url = "https://en.wikipedia.org/wiki/Philosophy" def find_first_link(url): ... 阅读全文
posted @ 2017-12-07 16:36 Zhentiw 阅读(350) 评论(0) 推荐(0) 编辑
摘要:# Python's list slice syntax can be used without indices # for a few fun and useful things: # You can clear all elements from a list: >>> lst = [1, 2, 3, 4, 5] >>> del lst[:] >>> lst [] # You can r... 阅读全文
posted @ 2017-12-07 15:39 Zhentiw 阅读(237) 评论(0) 推荐(0) 编辑
摘要:https://docs.python.org/2/library/collections.html 阅读全文
posted @ 2017-12-07 15:20 Zhentiw 阅读(201) 评论(0) 推荐(0) 编辑
摘要:>>> import itertools >>> for p in itertools.permutations('ABCD'): ... print(p) ('A', 'B', 'C', 'D') ('A', 'B', 'D', 'C') ('A', 'C', 'B', 'D') ('A', 'C', 'D 阅读全文
posted @ 2017-12-07 15:10 Zhentiw 阅读(200) 评论(0) 推荐(0) 编辑
摘要:The Python Standard Library has a lot of modules! To help you get familiar with what's available, here are a selection of our favourite Python Standar 阅读全文
posted @ 2017-11-28 15:50 Zhentiw 阅读(789) 评论(0) 推荐(0) 编辑
摘要:Python allows you to open a file, do operations on it, and automatically close it afterwards using with. In the example above we open a file, perform 阅读全文
posted @ 2017-11-28 15:35 Zhentiw 阅读(233) 评论(0) 推荐(0) 编辑
摘要:Default arguments are a helpful feature, but there is one situation where they can be surprisingly unhelpful. Using a mutable type (like a list or dic 阅读全文
posted @ 2017-11-27 21:53 Zhentiw 阅读(185) 评论(0) 推荐(0) 编辑
摘要:Python provides another useful built-in type: tuples. Tuples are used to store related pieces of information. Consider this example involving latitude 阅读全文
posted @ 2017-11-27 21:48 Zhentiw 阅读(466) 评论(0) 推荐(0) 编辑
摘要:Write a function, remove_duplicates that takes a list as its argument and returns a new list containing the unique elements of the original list. The 阅读全文
posted @ 2017-11-21 14:52 Zhentiw 阅读(348) 评论(0) 推荐(0) 编辑
摘要:Let's introduce a new string method, join: Also note thatjoin will trigger an error if we try to join anything other than strings. For example: 阅读全文
posted @ 2017-11-21 14:45 Zhentiw 阅读(497) 评论(0) 推荐(0) 编辑
摘要:In addition to accessing individual elements from a list we can use Python's slicing notation to access a subsequence of a list. Consider this list of 阅读全文
posted @ 2017-11-21 14:02 Zhentiw 阅读(346) 评论(0) 推荐(0) 编辑
摘要:One particularly useful string method is format. The format method is used to construct strings by inserting values into template strings. Consider th 阅读全文
posted @ 2017-11-13 20:13 Zhentiw 阅读(261) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示