Python
皮卡丘踢球
这个作者很懒,什么都没留下…
展开
-
Python开启简易HTTP服务
Python开启简易HTTP服务,只需要在某目录下执行: 如果你的目录下有一个叫「index.html」的文件名的文件,那么这个文件就会成为一个默认页,如果没有这个文件,那么,目录列表就会显示出来。效果:...原创 2022-06-13 13:18:32 · 1721 阅读 · 1 评论 -
TypeError: can only concatenate str (not "int") to str -----python学习
python中,拼接字符串较为特殊,需要以 正确写法为: msg = '我有%d'%(self.num) + '个苹果' 错误写法为: msg = '我有' + (self.num) + '个苹果'原创 2019-01-15 16:28:56 · 63413 阅读 · 6 评论 -
python中list置空与dict置空
错误写法: a = [] 正确写法: a[:] = [] 错误写法是将a重新指向一个对象,而a[:] = []是将数组中数据清空,地址值不变 dict同理,不过是需要调用clear()方法 ...原创 2019-02-21 23:31:45 · 1632 阅读 · 0 评论 -
TypeError: not enough arguments for format string
python学习过程中,报错: TypeError: not enough arguments for format string 将字符串中的%替换为%%,达到转义的效果原创 2019-02-17 22:05:43 · 2322 阅读 · 0 评论 -
python 判断变量类型
最近项目需要爬取数据,公款学习新知识。 在需要判断抓取的是否是有效数据时,判断变量类型 html_doc = """ <p class="title"><b><!--The Dormouse's story--></b></p> """ soup = BeautifulSoup(ht原创 2019-03-01 16:51:44 · 155 阅读 · 0 评论 -
Python TypeError: not enough arguments for format string
print('ShortInputException: 输⼊的⻓度是%d,⻓度⾄少应是%d' % result.length, result.atleast) python3.7版本。 打印带参数的语句,执行后报错 File "C:/Users/admin/PycharmProjects/Chief_PYPro/com/pyPractice/throwExcept.py", line...原创 2019-02-20 22:39:01 · 3704 阅读 · 0 评论