![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
一只学习的小透明
这个作者很懒,什么都没留下…
展开
-
TypeError: unsupported operand type(s) for +: 'builtin_function_or_method' and 'str'
class Dog: def __init__(self,name,age): self.name = name self.age = age def sit(self): print(str(self.name).title + "is now sitting.") def roll_over(self): ...原创 2019-12-23 00:01:28 · 1417 阅读 · 3 评论 -
Python getattr方法
>>>class A(object):... bar = 1... >>> a = A()>>> getattr(a, 'bar') # 获取属性 bar 值1>>> getattr(a, 'bar2') # 属性 bar2 不存在,触发异常Traceback (most re...原创 2018-08-22 20:13:32 · 237 阅读 · 0 评论 -
python ConfigParaser 用法
一般用来调整配置档,配置档一般是ini文件或者conf文件配置文件一般是一个一个section,每个 section下有很多组数值,一般是一一对应,不能存在数组的# database source[db]host = 127.0.0.1port = 3306user = rootpass = root# ssh[ssh]host = 192.168.1.101user ...转载 2018-08-22 20:28:03 · 862 阅读 · 0 评论 -
python使用codecs.open 读写
由于python中默认的编码是ascii,如果直接使用open方法得到文件对象然后进行文件的读写,都将无法使用包含中文字符(以及其他非ascii码字符),因此建议使用utf-8编码。使用方法 读 下面的代码读取了文件,将每一行的内容组成了一个列表。 import codecsfile = codecs.open('test.txt','r','utf-8')lines = [...转载 2018-08-22 21:13:09 · 2409 阅读 · 0 评论 -
Python compile() 函数
描述compile() 函数将一个字符串编译为字节代码。语法以下是 compile() 方法的语法:compile(source, filename, mode[, flags[, dont_inherit]])参数source -- 字符串或者AST(Abstract Syntax Trees)对象。。 filename -- 代码文件名称,如果不是从文件读取代码则传...转载 2018-08-22 21:41:19 · 2004 阅读 · 0 评论 -
出现this constructor takes no arguments
这个构造函数没有参数this constructor takes no arguments 1.一般需要检查对齐是否正常2.检查init的下划线是否正确,__init__是两个下划线原创 2018-09-03 10:46:40 · 545 阅读 · 0 评论 -
print时出现指向命令
打印时出现<__main__.person instance="" at="" 0x7fe9f0555170=""><__main__.person instance="" at="" 0x7fe9f05551b8="">是因为print 的对象是实例化后的对线,需要调用方法...原创 2018-09-03 10:50:39 · 328 阅读 · 0 评论 -
gui基类练习
from tkinter import *from tkinter.ttk import *#创建GUI的基类class GUIBase: def __init__(self): self.frame = Tk() self.frame.geometry('600x400+200+200') self.frame.resizable...原创 2019-05-07 18:36:47 · 186 阅读 · 0 评论