随笔分类 - Python基础
摘要:class Player(object): def __init__(self, uid, name, status=0, level=1): self.uid = uid self.name = name self.stat = status self.level = level class Pl
阅读全文
摘要:方式一:一个个的用函数实现 #_*_ encoding: utf-8 _*_ @author: ty hery 2019/1/12 import requests def getWeather(city): r = requests.get(u'http://wthrcdn.etouch.cn/we
阅读全文
摘要:最先版本的 from telnetlib import Telnet from sys import stdin, stdout from collections import deque class TelnetClient(object): def __init__(self, addr, po
阅读全文
摘要:set(),list(),tuple() 方法只接受一个值,这个值可以是列表或者是元组, 否则报错 TypeError: set expected at most 1 arguments, got 3 dict() 方法接受相当于默认参数,key不用引号'',用=号相连 sys.getsizeof(
阅读全文
摘要:# _*_ encoding: utf-8 _*_ @author: ty hery 2019/2/18 string = "hello" # %s打印时结果是hello print("string01=%s" % string) # output: string=hello # %2s意思是字符串
阅读全文
摘要:一,基本概念 Python代码由表达式和语句组成,并由Python解释器负责执行。它们的主要区别是“表达式”是一个值,它的结果一定是一个Python对象。当Python解释器计算它时结果可以是任何对象。例如42,1+2,int(‘123’),range(10)等。 表达式:赋值,是什么,产生结果,表
阅读全文
摘要:Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列。 注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符。 str = "00000003210Runoob01230000000"; print str.strip( '0' ); # 去除首尾
阅读全文