Python教程
Python教程:包含了所有代写案例以及部分答案
-
此段代码可以利用剪切板,完成自动复制粘贴等功能。 import sys import os.path import win32clipboard as w import win32con import win32api def getText():#读取剪切板 w.OpenClipboard() d = w.GetClipboardData(win32con.CF_TEXT) w.CloseClipboard() return d def setText(aString):#写入剪切板 w.Op … 继续阅读“Python使用剪切板代码”
:
-
import re pattern=re.compile(r’\| (\d+) \| (\d+) \|’) numset=set() all=”’ | 29266795 | 533 | | 29370116 | 533 | | 29467495 | 533 | | 29500404 | 533 | | 29500622 | 533 | | 29515964 | 530 | | 29516015 | 530 | | 29520954 | 530 | | 29520960 | 530 | | 29 … 继续阅读“python 利用正则表达式匹配并截取指定子串并去重”
:
-
#!/usr/bin/python #-*- coding:utf-8 -*- from ftplib import FTP #加载ftp模块 ftp=FTP() #设置变量 ftp.set_debuglevel(2) #打开调试级别2,显示详细信息 ftp.connect("IP","port") #连接的ftp sever和端口 ftp.login("user","password")#连接的用户名,密码 pri … 继续阅读“python ftplib模块制作ftp客户端”
:
-
#!/usr/bin/python #coding:utf-8 import xlrd import xlwt import requests import urllib import math import re pattern_x=re.compile(r’"x":(".+?")’) pattern_y=re.compile(r’"y":(".+?")’) def mercator2wgs84(mercator) … 继续阅读“python 从百度地图API接口批量获取地点的经纬度”
:
-
# Import python libs import os def is_writeable(path, check_parent=False): ”’ Check if a given path is writeable by the current user. :param path: The path to check :param check_parent: If the path to check does not exist, check for the ability to w … 继续阅读“python验证文件是否可读可写”
:
-
import os def get_cpu_load(): """ Returns a list CPU Loads""" result = [] cmd = "WMIC CPU GET LoadPercentage " response = os.popen(cmd + ‘ 2>&1′,’r’).read().strip().split("\r\n") for load i … 继续阅读“python计算windows的cpu使用率”
:
-
#coding: UTF-8 def arrage(temp_list): num = len(temp_list) for i in range(1,num): for j in range(i): if temp_list[i] >= temp_list[j] and j == (i-1): break elif temp_list[i] <= temp_list[j] and j == 0: temp_list.insert(0,temp_list.pop(i)) elif t … 继续阅读“python实现插入排序”
:
-
class ShoppingCart(object): """Creates shopping cart objects for users of our fine website.""" items_in_cart = {} def __init__(self, customer_name): self.customer_name = customer_name def add_item(self, product, price): … 继续阅读“python 学习,使用类模拟购物车代码”
:
-
目前处在学习python的阶段,昨天看到了python的socket模块,分别实现TCP、UDP时间戳回显。 1、tcp通信server和client代码 # tcpServer.py #!/usr/bin/python # -*- coding: utf-8 -*- from socket import * from time import ctime HOST = ” PORT = 21156 BUFSIZE = 1024 ADDR = (HOST,PORT) tcpServerSock … 继续阅读“Python的socket编程”
: