Quantcast
Channel: 编程学习 –月与灯依旧
Browsing latest articles
Browse All 19 View Live

python遍历文件脚本实例

自己写的一个Python遍历文件脚本,对查到的文件进行特定的处理。没啥技术含量,但是也记录一下吧。 #!/usr/bin/python # -*- coding: utf-8 -*- import sys import os import shutil dir = "/mnt/Packages" class Packages: def __init__(self,srcdir,desdir):...

View Article



Python tips –轻松转换列表与字符串

There are a few useful tips to convert a Python list (or any other iterable such as a tuple) to a string for display. First, if it is a list of strings, you may simply use join this way: >>>...

View Article

使用pytest进行批量测试

Pytest是python的一个测试模块,可以编写一些简单的测试用例,也可以用来进行一些批量测试,下面简单介绍一下。 1,安装 $ pip install -U pytest or $ easy_install -U pytest $ py.test --version 2,基础语法 #!/usr/bin/python import pytest def func(x): return x + 1...

View Article

Python读取配置文件模块ConfigParser

1,ConfigParser模块简介 假设有如下配置文件,需要在Pyhton程序中读取 $ cat config.ini [db] db_port = 3306 db_user = root db_host = 127.0.0.1 db_pass = xgmtest [SectionOne] Status: Single Name: Derek Value: Yes Age: 30 Single:...

View Article

一些初级python面试题

一些初级python面试题,这里简单罗列一下 # 反转字符串, 这个是最常见的 # 比如给一个字符串hello,将其反转为olleh def reverse(str): alist = list(str) alist.reverse() new_str = ''.join(alist) return new_str # 写一个方法打印如下内容,每一行打印5个 # server1, server2,...

View Article


Django parse a json/dictionary reminder on template

如果想在一个Django template里引入json, 正确的template写法为 python的views.py的写法 # -*- coding: utf-8 -*- from django.shortcuts import render from django.http import Http404, HttpResponse def get_product(request):...

View Article

交叉编译golang程序

本文演示了在ubuntu16.04上交叉编译golang程序的过程 配置本地golang环境 $ wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz $ tar zxvf go1.10.2.linux-amd64.tar.gz $ sudo mv go /usr/local/ $ echo 'export...

View Article

Image may be NSFW.
Clik here to view.

HTML栅格化示例

如果需要将一个DIV平均分割成几个小方格, 栅格化是比较好的解决方案, 本文演示一下 CSS代码: <style> .features .feat_list{ width: 60%; margin: 20px auto; outline: 1px solid blue; } .features .feat_list::before, .features...

View Article


python字符串对齐

对于基本的字符串对齐操作,可以使用字符串的 ljust() , rjust() 和 center() 方法。比如: >>> text = 'Hello World' >>> text.ljust(20) 'Hello World ' >>> text.rjust(20) ' Hello World' >>>...

View Article


Javascript Array

Handle element in an Array const hobbies = ["sports", "cooking", "reading"]; console.log(hobbies[0]); # Get single element hobbies.push("surfing"); # Add new element to the end...

View Article
Browsing latest articles
Browse All 19 View Live




Latest Images