自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 收藏
  • 关注

转载 Python » Documentation » The Python Tutorial »8 Errors and Exceptions

8. Errors and ExceptionsUntil now error messages haven’t been more than mentioned, but if you have tried out the examples you have probably seen some. There are (at least) two distinguishable kinds ...

2018-08-24 01:15:33 264

转载 Python » Documentation » The Python Tutorial »input and output

7. Input and OutputThere are several ways to present the output of a program; data can be printed in a human-readable form, or written to a file for future use. This chapter will discuss some of the...

2018-08-21 16:03:05 242

转载 Python 3.7» Documentation » The Python Tutorial »

6. ModulesIf you quit from the Python interpreter(解释器) and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program...

2018-08-17 01:35:10 442

原创 循环语句常用技巧

一、通过切片实现循环迭代访问列表时直接修改列表的值例如:words=["cat","window","defenstrate"]for w in words[:]:    if len(w)>6:        words.insert(0,w)print(words)如下案例就没有利用切片直接通过循环在循环内修改,程序就会卡住无法运行words=["cat","window...

2018-08-13 22:16:20 464

原创 Data Structures

5. Data StructuresThis chapter describes some things you’ve learned about already in more detail, and adds some new things as well.5.1. More on ListsThe list data type has some more methods. Her...

2018-08-13 21:39:48 327

翻译 The Python Tutorial 4

4. More Control Flow ToolsBesides the while statement just introduced, Python knows the usual control flow statements known from other languages, with some twists.4.1. if StatementsPerhaps the m...

2018-08-12 00:47:17 417

翻译 The Python Tutorial(教程)3

3. An Informal(非正式) Introduction to PythonIn the following examples, input and output are distinguished by ( 被区分)the presence or absence of prompts (>>> and …): to repeat the example, you m...

2018-08-12 00:43:18 413

翻译 The Python Tutorial(教程)2

2. Using the Python Interpreter2.1. Invoking(调用) the InterpreterThe Python interpreter is usually installed(安装) as /usr/local/bin/python3.7 on those machines where it is available; putting /usr/lo...

2018-08-11 23:46:00 282

翻译 The Python Tutorial(教程)

The Python Tutorial(教程)Python is an easy to learn, powerful programming language. It has efficient(有效的) high-level data structures and a simple but effective approach(途径) to object-oriented programm...

2018-08-11 00:16:19 2618

原创 python3.7 socket 下载服务段的文件

服务器段代码__author__ = 'Administrator'import socket,timehost="localhost"port=9090addr=(host,port)server=socket.socket(socket.AF_INET,socket.SOCK_STREAM)server.bind(addr)server.listen(6)while Tr...

2018-08-01 15:45:57 265

原创 python3.7 使用socket实现TCP简单实现ssh

客户端import socketclient=socket.socket(socket.AF_INET,socket.SOCK_STREAM)client.connect(("localhost",9090))while True: cmd=input(">>:").strip().encode("utf_8") if cmd is not None and ...

2018-07-31 01:16:48 1602

原创 socket下载文件

客户端脚本__author__ = 'Administrator''''创建socket连接服务器用户输入下载命令罚送数据到服务器段接收服务器段发回的数据保存到一本地一个新的文件'''import socketclient=socket.socket(socket.AF_INET,socket.SOCK_STREAM)client.connect(("localhost"...

2018-07-30 01:20:21 1388

原创 python3 使用socket实现简单的tcp单个进程之间的通信

#以下代码是客户段代码import socketclinet=socket.socket(socket.AF_INET,socket.SOCK_STREAM)clinet.connect(("localhost",9090))while True: date=input("请输入你要发送给消息:") if date is None: break ...

2018-07-29 23:21:07 573

原创 正则表达式2

本文参照python 核心编程第一章正则表达式#1、match函数的使用import rem=re.match("foo","foo")if m is not None: print(m.group())'''match 如果匹配成功,返回一个匹配对象,不成功则返回None如果我们不使用if判断就使用m.group(),在匹配不成功时就会抛出异常import rem=...

2018-07-23 00:33:57 111

原创 python3正则表达式

#############################常见正则表达式和特殊符号(元字符)###########################import re1、直接使用字符串中的值进行匹配str1="87alalsdkj34878273\nalkjsldkjfalsdjalksd2klajlfkasjlkdf"print(re.match("al",str1)) #从 字符匹配串...

2018-07-20 01:13:51 175

转载 Socket Programming HOWTO

Socket Programming HOWTO************************Author:   Gordon McMillanAbstract^^^^^^^^Sockets are used nearly everywhere, but are one of the most severelymisunderstood technologies aroun...

2018-07-17 00:23:02 317

转载 ipaddress.txe

An introduction to the ipaddress module***************************************author:   Peter Moodyauthor:   Nick CoghlanOverview^^^^^^^^This document aims to provide a gentle introductio...

2018-07-16 23:38:50 462

原创 python 时间模块

'''本文源自:https://www.cnblogs.com/renpingsheng/p/6965044.html 1.时间戳(timestamp)的方式:通常来说,时间戳表示的是从1970年1月1日开始按秒计算的偏移量(time.gmtime(0)) 此模块中的函数无法处理1970纪元年以前的时间或太遥远的未来(处理极限取决于C函数库,对于32位系统而言,是2038年) 2.U...

2018-07-16 15:41:52 169

翻译 IO.py

16.2. "io" --- Core(核心) tools for working with streams(数据流)****************************************************Source code(代码):** Lib/io.py源代码=====================================================...

2018-07-16 01:02:10 418

原创 pythone IO.py 文件源代码

#io 模块主要是提供了用于处理数据流的核心工具'''数据流: 文本数据流 txt i/o 二进制数据流 binary io 原始数据流 raw io'''#创建文本流的方式#方式1import iof = io.StringIO("some initial text data")f.close()#方式2f=open("a.txt","r",encod...

2018-07-16 01:00:01 576

原创 python 装饰器实例,以及解释版本

__author__ = 'guode''''装饰器: 不修不修改源代码 不修改原函数的 装饰器本事就是个函数'''import timedef zhuangshiqi(func): def decoc(): start_time=time.time() func() end_time=time.time()...

2018-07-12 22:58:52 264

原创 Python中使用pip安装第三方包

通过pip安装xlwt包使用pip安装xlrd

2018-07-11 19:09:23 816

原创 python中的文件操作

######################################### Python中文件的操作 #########################################################'''文件夹的操作: 1、创建文件夹 2、删除文件夹'''#在指定的目录下新建目录import os#os.mkdir("F:\\new") ...

2018-07-11 17:57:21 187

原创 python函数学习笔记

#函数的定义def fucn_name(): pass return 0#def 关键字用来定义函数,func_name 是函数名,()中可以加函数的参数 pass 是函数体,return为函数结束返回值#实例def add(x,y): return x+y#定义一个求和的函数 函数返回的数据类型为x+y的数据类型#return 可以有多个返回值def re...

2018-07-11 14:58:15 123

原创 列表,循环,判断,格式化输出等综合操作第一个综合程序

"""程序:购物车程序需求:1.启动程序后,让用户输入工资,然后打印商品列表2.允许用户根据商品编号购买商品3.用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒4.可随时退出,退出时,打印已购买商品和余额"""#用户登录后需要加载的变量product_list=[ ["xiaomi6",2499], ["hu...

2018-07-11 02:56:02 103

原创 python3中字典的相关操作

"""字典的定义:{"key":value}字典的关键字是唯一的,所以字典中没有重复的关键字字典是通过关键字来读查询,所以字典是无序的"""student={"name":"guode","age":29,"sex":"man"}print(student)#由于字典是无序的所以只能通过关键字来读取字典的prin

2018-07-10 23:53:02 469

原创 python字符串学习实例

"""字符串操作"""#######################capitalize字符串的首字母大写##########################a="aliC"a.capitalize() #将字符传递额首字母大写但是不修改a的值print(a.capitalize())print(a.count("a"))#将字符串中的所有大写字母转换成小写字母print(a....

2018-07-10 01:46:41 323

原创 python中元组学习实例

"""元组:类似于列表,一但创建就不可以修改只能对元组进行查询和读取"""#元组的定义以及调用a=(1,2,4,6)print(a[0])print(a[:])print(a[:len(a)])print(a[1:3])#元组的方法print(a.count(1)) #统计元组中元素的个数print(a.index(1)) #查找元素在元组中的索引...

2018-07-10 01:45:20 405

原创 python3中列表操作的各种实例

###################################列表中元素的访问#########################################a=["zhangsan","zhangsan ","lisi","lisi"]print(a)b=a[0]print(b)#单独读取列表中的元素的方法可以通过下表的方法去print(a[0:3])print(a...

2018-07-10 01:43:52 1901

原创 python中集合的常用操作

#两个集合合并name={"zhangsan","lisi","wagnwu"}print(name.union({34,89,"zhangsan"}))#清空集合name={"zhangsan","lisi","wagnwu"}print(name.clear())

2018-07-06 00:38:47 164

原创 discard

#Remove an element from a set if it is a member.#If the element is not a member, do nothing.name={"zhangsan","lisi","wagnwu"}name.discard("zhangsan")print(name)

2018-07-05 23:33:18 1922

原创 difference_update() python3

你可以参考https://mp.csdn.net/postedit/80934322中的difference方法两者可以达到实现同样的方法,只是使用difference()方法不改变set1的值而使用difference_update会改变set1 的值#使用difference_update会更新set1的值 返回值为noneset1=set(["zhangsan","lisi","wangw...

2018-07-05 23:25:24 851 1

原创 set.difference() 的用法(python3)

python中对difference的解释如下:例如第一个运算方法set1-(set1和set2中的相同元素):结果就是{“lisi”“wangwu”}第二个输运算方法set1-(set1和set2中的相同元素)-(set1和set3中的相同元素):结果为:{"wangwu"}...

2018-07-05 23:06:10 7044

原创 pytho3中set.add(tuple)的用法

语法:set.add(tuple) #Return the difference of two or more sets as a new set.以上程序为在字典中添加元组,运行结果如下:

2018-07-05 22:49:22 906

原创 Python3.7中元组的定义 集合的定义 集合中添加元素

#定义一个元组(tuple),tuple=("zhangsan","lisi","wangwu ") #定义一个元组#元组不能进行增删改,只有count方法和index方法tuple.count("zhangsan")tuple.index("zhangsan")#集合(set)的定义:'''通过set(参数)函数定义set=set([])set=set(())set=set...

2018-07-05 19:43:49 3102

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除