Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Browsing all 9596 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

用Python中的tkinter模块作图

tkinter 可以用来创建完整的应用程序,比如简单的字处理软件,还有简单的绘图软件。 一、创建一个可以点的按钮 用tkinter创建一个带按钮的简单程序,代码如下: >>> from tkinter import* >>> tk = Tk() >>> btn = Button(tk,text = "click me") >>>...

View Article


Image may be NSFW.
Clik here to view.

matplotlib绘图――折线图

1. line chart import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2 * np.pi, 100) y1, y2 = np.sin(x), np.cos(x) plt.plot(x, y1) plt.plot(x, y2) plt.title('line chart') plt.xlabel('x')...

View Article


使用Python操作SQLite

创建数据库及表 首先,创建数据库,以及数据库中的表。在使用connect()连接数据库后,就可以通过定位指针cursor,来执行SQL命令: importsqlite3 # test.db is a file in the working directory. conn = sqlite3.connect("test.db") cur = conn.cursor() # create tables...

View Article

Image may be NSFW.
Clik here to view.

Intro to Pygal: A Python SVG Charts Creator

SVG (Scalable Vector Graphics) is an image format which defines vector-based graphics in XML format. In this tutorial, you'll have a look at how to get started with using Pygal, a python SVG...

View Article

Image may be NSFW.
Clik here to view.

快速实现python c扩展模块

快速实现python c扩展模块 40分钟前来源:cnblogs 1 python扩展模块的组成在python中,对于一些和系统相关的模块或者对性能要求很高的模块,通常会把这个模块C化。扩展模块中主要包含下面几个部分:...

View Article


Django-REST User Level Permissions and Object Level Permissions

Let us cosider the scenario of Authors, Books, Readers. Authors are only allowed to write the books Readers are only allowed to read the Books. models.py from django.utils.translation import...

View Article

Python-SWIG 初探以及其 gdb 调试

SWIG is used with different types of target languages including common scripting languages such as javascript, Perl, php, python, Tcl and Ruby. 上面那段是 SWIG 的官网介绍,简单地说,SWIG 是一个用于 C/C++ 和高层脚本语言交互的工具。脚本语言在...

View Article

Image may be NSFW.
Clik here to view.

matplotlib绘图――line

1. line chart import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2 * np.pi, 100) y1, y2 = np.sin(x), np.cos(x) plt.plot(x, y1) plt.plot(x, y2) plt.show() 2. 线的样式 (1)颜色 plot 方法的关键字参数...

View Article


Grab this full-on Python Programming Bootcamp for just $39 (regularly $1,094)

If you’re eyeing a career in coding, you won’t find many programming disciplines that’ll take you further than a firm command of python. So jump in with both feet and learn everything there is to know...

View Article


Image may be NSFW.
Clik here to view.

Guide to Encoding Categorical Values inPython

Introduction In many practical Data Science activities, the data set will contain categorical variables. These variables are typically stored as text values which represent various traits. Some...

View Article

认识Django的Class-Based-View

学习Django非常简单,几乎不用花什么精力就可以入门了。配置一个url,分给一个函数处理它,返回 response ,几乎都没有什么很难理解的地方。 写多了,有些问题才逐渐认识到。比如有一个view比较复杂,调用了很多其他的函数。想要把这些函数封装起来,怎么办?当然,可以用注释 #------view------ 这样将函数隔离开,这种方法太low了,简直是在骗自己,连封装都算不上。...

View Article

Image may be NSFW.
Clik here to view.

技巧收集-M1701

To use the decorator, apply it as innermost decorator to a view function. When applying further decorators, always remember that the route() decorator is the outermost. 2017.01 HTML的...

View Article

Image may be NSFW.
Clik here to view.

A Python scikit Machine Learning Demo

I don’t often use the scikit-learn library, so I thought I’d do a quick demo just to refresh my memory. The scikit-learn library is a collection of python code modules that can do machine learning...

View Article


使用 Python 自动将数据库备份到 Dropbox 的脚本

最近,正好发生了一件大事,就是 GitLab 的运维同学不小心删除了生产的数据,虽然 GitLab 已经骇人听闻的准备了五种备份机制,但是,仍然导致他们丢失了将近 6 个小时的用户数据,尤其对他们声誉的损失,是根本无法估量的。反思一下,这个博客 Becomin’...

View Article

Django for Flask users

I’m using Django for a serious project for the first time. I had played with Django a couple of times before, but I’m a long-time Flask fanboy and I invariably gave up in frustration (“why would...

View Article


Image may be NSFW.
Clik here to view.

PyDev of the Week: Michael Kennedy

This week we welcome Michael Kennedy ( @mkennedy ) as our PyDev of the Week! Michael is an author and speaker. He is also a python and MongoDB enthusiast, and an entrepreneur. He is the host of the...

View Article

Image may be NSFW.
Clik here to view.

Faster video file FPS with cv2.VideoCapture and OpenCV

Have you ever worked with a video file via OpenCV’s cv2 . VideoCapture function and found that reading frames just felt slow and sluggish? I’ve been there ― and I know exactly how it feels. Your...

View Article


PyCharm: Let’s Write a Game: Hangout with PyLadies Pune

In early January I was invited by PyLadies Pune to do a hangout. We spent an hour writing a 2d game in python, covering a number of Python development skills along the way. I’d love to repeat this, so...

View Article

Integration Tests with CherryPy and requests

CherryPy is a great way to write simple http backends, but there is a part of it that I do not like very much. While there is a documented way of setting up integration tests, it did not work well for...

View Article

Image may be NSFW.
Clik here to view.

Write your first web crawler in Python Scrapy

Thescraping series will not get completed without discussing Scrapy . In this post I am going to write a web crawler that will scrape data from OLX’s Electronics & Appliances’ items. Before I get...

View Article
Browsing all 9596 articles
Browse latest View live