摘要:
# -*- coding: utf-8 -*- """ Created on Wed May 9 14:12:25 2018 @author: JJ """ #12306账号 myuser="" mypasswd="" import urllib.request import re import ssl import urllib.parse import http.cookiejar imp... 阅读全文
该文被密码保护。 阅读全文
摘要:
数据库(右键打开位置,找到users点进去,第一个.db即文件列表,内含hd5),复制到同一目录: 阅读全文
摘要:
#!coding=utf-8 import requests import re import time import json from requests.packages.urllib3.exceptions import InsecureRequestWarning import pandas as pd requests.packages.urllib3.disable_warnings... 阅读全文
摘要:
import pymysql db = pymysql.connect(host='localhost', user='root', password='pz2212', port=3306, db='spiders') cursor = db.cursor() data = { 'id': '20120001', 'name': 'Bob', 'age': 20 } t... 阅读全文
摘要:
import mitmproxy.http from mitmproxy import ctx, http class Joker: def request(self, flow: mitmproxy.http.HTTPFlow): if flow.request.host != "www.baidu.com" or not flow.request.path.sta... 阅读全文
摘要:
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec from seleni... 阅读全文
摘要:
#!python3 #updateProduce.py-更正指定产品 成本价格(第二列) import openpyxl wb=openpyxl.load_workbook('produceSales.xlsx') sheet=wb.active #或sheet=wb['Sheet'] # 需要更新成本价格的产品,字典格式 PRICE_UPDATES = {'Garlic': 3.07, ... 阅读全文
摘要:
import requests from pyquery import PyQuery as pq url='https://www.zhihu.com/explore' headers={ 'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Geck... 阅读全文
摘要:
grid = [['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 阅读全文
摘要:
name = ''#名字为空即代表False while not name:#not name=False即 真,将执行循环体 print('Enter your name:') name = input()#给name赋值,如输入了空以外值,不会再有下一个循环while print('How many guests will you have?') numOfG... 阅读全文
摘要:
#让用户输入一个宠物名字,然后检查该名字是否在宠物列表中 myPets = ['Zophie', 'Pooka', 'Fat-tail'] print('Enter a pet name:') name = input() if name not in myPets: print('I do not have a pet named ' + name) else: print(n... 阅读全文
摘要:
#! python3 # mapIt.py - Launches a map in the browser using an address from the # command line or clipboard. import webbrowser, sys, pyperclip #如果命令输入了参数,就从命令里得到地名 if len(sys.argv) > 1: # Get add... 阅读全文
摘要:
import requests,re,json,time from requests.exceptions import RequestException headers={ 'User-Agent':'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' } def get_one_page(url): r=requests.g... 阅读全文
摘要:
#匹配电话,例如:415-555-4242 def isPhoneNumber(text): if len(text) != 12: return False for i in range(0, 3): if not text[i].isdecimal(): return False if text[3] != '-... 阅读全文
摘要:
import traceback try: raise Exception('这是一个错误信息') except: errFile=open('err.txt','w') errFile.write(traceback.format_exc()) errFile.close() print('错误信息已经写入err.txt文件中') 阅读全文
摘要:
import requests,bs4,os #利用 requests 模块下载页面 url='http://xkcd.com' os.makedirs('xkcd', exist_ok=True) #创建一个文件夹xkcd while not url.endswith('#'): res=requests.get(url) res.raise_for_status() #没... 阅读全文
摘要:
class Dog(): def __init__(self,name,age): self.name=name self.age=age def sit(self): print(self.name.title()+' 现在坐下了') def roll_over(self): print(self.name... 阅读全文
摘要:
def hello(): print('Howdy!') print('Howdy!!!') print('Hello there.') hello() 阅读全文
摘要:
import random heads = 0 for i in range(1, 1001): if random.randint(0, 1) == 1: heads = heads + 1 if i == 500: print('Halfway done!') print('Heads came up ' + str(heads) + ' ti... 阅读全文