"""
接收控制台的输入
How old are you?
18
How tall are you ?
180
How much do you weigh?
50
So ,you are ‘18‘ old,‘180‘ tall and ‘50‘ heavy,python3的控制台输入函数时input();
"""
print("How old are you?");age=input();print("How tall are you ?");height=input();print("How much do you weigh?");weight=input();print("So ,you are %r old,%r tall and %r heavy," %(age,height,weight));
原文:https://www.c...
我最近有一个项目,使用Python在win32下开发一个COM组建,该COM组建其中一个方法是获取本地电脑的MAC地址。需求很简单,虽然我是Python新手中的新手,但我还是会使用搜索引擎进行搜索。百度一下,发现大部分都介绍使用import UUID获取MAC地址,或使用os.popen("ipconfig /all")的方式获取。而后者容易受到操作系统中英文环境影响。如这篇文章:http://www.cnblogs.com/Jerryshome/archive/2011/11/30/2269365.html所以,我很乖的使...
1、pymysql模块安装与引入安装pip install PyMySQL引入import pymysql2、数据库的操作下图查找连接数据库,源码的方法,以及参数怎么配置的可参考 数据库的操作步骤:步骤1:引入pymysql模块 import pymysql步骤2:连接数据库,返回连接对象 注意:charset="utf8"指定编码方式,没有-con = pymysql.connect(host="127.0.0.1", user="root", port=3306, password="123456",charset="utf8")步骤3:创建一个游标对象cur = con.cursor()...
取得时间相关的信息的话,要用到python time模块,python time模块里面有很多非常好用的功能,你可以去官方文档了解下,要取的当前时间的话,要取得当前时间的时间戳,时间戳好像是1970年到现在时间相隔的时间。你可以试下下面的方式来取得当前时间的时间戳:import timeprint time.time()输出的结果是:1357723206.31但是这样是一连串的数字不是我们想要的结果,我们可以利用time模块的格式化时间的方法来处理:time.localtime(tim...
物理机内存检查,#!/usr/bin/env python
# -*-coding:UTF-8 -*-
import osmemdict = dict()
memditail = dict()#os.popen()
os.system(' dmidecode -t memory >./mem.txt ')
memstr=os.popen('cat ./mem.txt')
mem_count=os.popen("cat ./mem.txt |grep 'Number Of Devices' |awk -F':' '{print $2}'").read()#mem_count = memstr.read().count("Memory Device")
#mem_count = os.popen(" dmidecode -t 17").read()Device_info ...
财经数据接口包tushare的使用(一)Tushare是一款开源免费的金融数据接口包,可以用于获取股票的历史数据、年度季度报表数据、实时分笔数据、历史分笔数据,本文对tushare的用法,已经存在的一些问题做一些介绍。一:安装tushare为避免由于依赖包缺失导致安装失败,请先安装anaconda,百度网盘地址: 链接:http://pan.baidu.com/s/1qYDQUGs 密码:6wq8 安装直接一直下一步即可 安装完成之后,anaconda会自动配置环境变量,直接就可...
#coding=utf-8def getbin(a):out = ""# 辗转相除法while (1):div = a // 2mod = a % 2out += str(mod)if (div == 0):breaka = divreturnout[::-1]print(getbin(11))输出1011 参考:https://www.nuoweb.com/scripts/3158.htmlhttps://jingyan.baidu.com/article/f0e83a255ca20422e59101f5.html 原文:https://www.cnblogs.com/sea-stream/p/11324105.html
1、获取网站课程的分类地址;‘‘‘
爬取屌丝首页,获取每个分类名称和链接
‘‘‘import requests
from lxml import etreeheaders = {‘User-Agent‘:‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36‘,
}
def get_class_data():list_data = []url = ‘http://www.diaosiweb.net/index.html‘responese = requests.get(url,headers=headers)responese.encoding...
来这里找志同道合的小伙伴!↑↑↑ Python应用现在如火如荼,应用范围很广。因其效率高开发迅速的优势,快速进入编程语言排行榜前几名。本系列文章致力于可以全面系统的介绍Python语言开发知识和相关知识总结。希望大家能够快速入门并学习Python这门语言。本次课程是在掌握python基础之上进行的。基础没有学习的话建议先查看文章学习基础目录:Python开发实战系列教程-链接汇总,持续更新。进行学习。最近几天感冒中,四肢乏力以及...
python自动获取项目路径在windows和mac的不同import os
# 获取项目路径
project_path = os.path.abspath(os.path.join(os.path.dirname(os.path.split(os.path.realpath(__file__))[0]), ‘.‘))
# test_case_path = project_path+"\\src\\test_case"
test_case_path = project_path+"//src//test_case"# mac环境
# print u‘日志路径:‘+log_path
# 测试报告存储路径,并以当前时间作为报告名称前缀
# 获取到当前文件的目录,并检...
全文:https://mp.weixin.qq.com/s/tIsJr5br3D13-Lgc6w2ntg 刚刚,又一个机器学习人气课程冲上GitHub热榜,一天之内新增了近700 star,一下子登上热榜第四。这套课程名为A Machine Learning Course with Python(Python机器学习课程),其介绍中只有一句话:这是一套容易理解并且简单的Python机器学习课。入门级资源、门槛降到最低,这在不少网友心里种了草,推特网友纷纷转推,表示期待着有空好好学习一下。里面都有啥?“容易理解...
# coding=gbkimport osimport os.path #读取目录下的所有文件,包括嵌套的文件夹def GetFileList(dir, fileList): newDir = dirif os.path.isfile(dir): fileList.append(dir) elif os.path.isdir(dir):for s in os.listdir(dir): # 如果需要忽略某些文件夹,使用以下代码 # if s == "xxx": # continue newDir = os.path.join(dir, s) GetFileList(newDir, f...
In [17]: now.strftime(%a),now.strftime(%w)
Out[17]: ('Mon', '1')Directive Meaning
%a Weekday name.
%A Full weekday name.
%b Abbreviated month name.
%B Full month name.
%c Appropriate date and time representation.
%d Day of the month as a decimal number [01,31].
%H Hour (24-hour clock) as a decimal number [00,23].
%I Hour (12-hour clock) as a decimal number [01,12].
%j Day of the year as...
import requests
from retrying import retrydef is_request_exception(e):print(e)return Truegetcookie=‘‘‘GET http://www.xxx.com HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, d...
#coding=utf-8from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptionimport unittest,timeimport requests#登录模块函数def login(): u‘‘‘gdtmpd登录‘‘‘ driver=webdriver.Chrome() driver.get(‘登录地址url‘) nowhandle=driver.current_window_handle print "nowhandle:%s"%nowhandle driver.implicitly_wait(30) driver.find_element_by_link_text(u‘QQ登...