python
来自流星
这个作者很懒,什么都没留下…
展开
-
python 类知识
# study python class 2019-02-13# 创建Dog类, 每个实例都将存储名称和年龄,并赋予其 sit() 蹲下 和 roll_over() 打滚的能力class Dog(): def __init__(self, name, age): '''初始化属性name和age''' self.name = name ...原创 2019-02-15 10:35:55 · 94 阅读 · 0 评论 -
python 创建类时遇到的问题 TypeError: Car() takes no arguments
在创建python 类,实例化Traceback (most recent call last): File "E:/PythonDemo/com/song/python_demo_class.py", line 72, in <module> my_car = Car('audi', 'a4', 2019)TypeError: Car() takes no argum...原创 2019-02-14 10:03:23 · 8313 阅读 · 2 评论 -
python django Reverse for 'new_entry' with arguments '('',)' not found.
在使用django form表单出现以下错误django.urls.exceptions.NoReverseMatch: Reverse for 'new_entry' with arguments '('',)' not found. 1 pattern(s) tried: ['new_entry/(?P<topic_id>\\d+)/$']功能描述: ...原创 2019-02-20 16:54:26 · 4926 阅读 · 2 评论 -
Both 'fieldsets' and 'fields' are specified.
在使用django的过程中 我们可能会遇到这个错误,这是因为在你的admin中既有 fieldsets 也有fields 这是我们只需要把他们删除一个就可以运行了。fields和fieldsets是一个东西。...原创 2019-03-21 10:20:42 · 449 阅读 · 0 评论 -
python ** 和 * 的区别和注意点
1.计算方面: * 表示乘法 ** 表示指数幂运算2. 作为函数的参数: 1)调用函数时 test(*args): * 表示传入的参数args是一个元组,把元组中的每一个元素按照次序作为参数传入, 比如上面这个代码,如果 args 等于(1, 2, 3) ,那么这个代码就等价于 test(1, 2, 3) 。 ...转载 2019-02-12 18:03:21 · 489 阅读 · 0 评论 -
python pycharm 导入模块问题
问题:Traceback (most recent call last): File "E:\PythonDemo\com\song\pizza_test.py", line 7, in <module> p.show_hello() AttributeError: module 'pizza' has no attribute 'show_hello'将模块...转载 2019-02-12 17:24:46 · 2161 阅读 · 1 评论 -
python list
# study python 2019-02-11fruits = ['math','english','java']# 新增元素fruits.append("123")print(fruits)# 在指定的位置,新增元素fruits.insert(0,"song")print(fruits)# 删除元素del fruits[0]print(fruits)# 删...原创 2019-02-12 16:21:13 · 95 阅读 · 0 评论 -
python 继承以及导入类
# study python class 2019-02-15from person import Person''' 导入类 随着你给类不断的添加能,文件可能会变得很长。 python允许你将类存储在模块中,然后主程序导入所需的模块'''ning = Person("小明", 20, '居住在上海')print(ning.get_desc_info())p...原创 2019-02-15 10:36:56 · 775 阅读 · 0 评论 -
python file 文件相关知识
# study python 2019-02-15""" 从文件中读取数据: 文本文件可存储的数据量多得难以置信, 天气数据、交通数据、社会经济数据、文学作品等。 每当需要分析或者修改存储在文件的信息时,读取文件很有用, 对于数据分析的程序来说尤其如此。"""abc_path = r'file\abc.txt'# 读取整个文件with open(ab...原创 2019-02-15 16:54:14 · 206 阅读 · 0 评论 -
pycharms 如何退出 python shell
(venv) E:\learning_log>python manage.py shell通过执行以下函数可以退出shell模式>>> exit() python 安装 bootstrap3pip install django-bootstrap3原创 2019-02-21 15:39:56 · 5002 阅读 · 0 评论 -
python TypeError: unsupported operand type(s) for +: 'int' and 'str'
python 中 打印时,不支持 2 + "字符串"print(2+"test")会抛出如下异常 : python TypeError: unsupported operand type(s) for +: 'int' and 'str'“+” 在python中有两个作用 一个是数学运算符,是用来在整型、浮点型等数学之间进行加法操作的。 ...原创 2019-02-12 09:24:58 · 33606 阅读 · 1 评论 -
python 字典知识点
# study python 2019-02-11# 使用字典 在python中 字典是一系列键值对,每个键都与一个值相互关联# 存储一些外星人 颜色和点数alien_0 = {'color':'red','points':5}print(alien_0['color'])# 访问字典里面的值print(alien_0['points'])# 往字典里面添加值alien...原创 2019-02-12 16:18:42 · 270 阅读 · 0 评论 -
python 函数
# study python 2019-02-12# 定义简单函数def greet_user(): print("Hello world")greet_user()# 向函数传递值def greet_username(show_name): print(show_name)greet_username("my name is jack")# 传...原创 2019-02-12 16:19:31 · 142 阅读 · 0 评论 -
python if else
# study python 2019-02-11cars = ['audi','bmw','toyota','subaru']for car in cars: if car == 'bmw': print(car.upper()) else: print(car.lower())car = "Audi"# python 咋检查是否相...原创 2019-02-12 16:20:06 · 7658 阅读 · 0 评论 -
python input
# study python 2019-02-12# 用户输入 input()与while循环name = input("please enter your name!")print("welcome to you : " + name)# 指定输入的类型是intage = input("please enter your age!")print("your age is : "...原创 2019-02-12 16:20:38 · 773 阅读 · 0 评论 -
pycharms debug调试
在使用pycharms debug 时, 发现使用F8时一直在python源码里面调试,也无法调到自己定义的断点处。后来发现是IDEA 与 pycharms debug调试 有些区别ALT + SHIFT + F7 是一行一行的执行, 可以跳入子函数断点内容ALT + SHIFT + F8 一行一行执行...原创 2019-03-21 15:37:35 · 111 阅读 · 0 评论