![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python基础语法学习笔记
BIM 刘大波
这个作者很懒,什么都没留下…
展开
-
python 取整数的几种方式
1、向下取整向下取整直接用内建的int()函数即可: 1 2 3 >>> a = 3.75 >>> int(a) 3 2、四舍五入对数字进行四舍五入用round()函数: 1 2 3 >>> r...转载 2019-06-19 08:11:37 · 3915 阅读 · 0 评论 -
python发邮件,群发邮件
import smtplibfrom email.mime.text import MIMEText#文字from email.mime.image import MIMEImage#图片from email.mime.multipart import MIMEMultipart#多类型from email.header import Header#文件主题'''请你按住ctr...原创 2019-06-27 21:56:52 · 829 阅读 · 0 评论 -
python自动修改ip地址第一版本
因为经常出差,公司用的是固定ip,所以每次回来都要修改,麻烦的很,网上查了下代码,顺便学习了wmi模块和pyinstaller。需要wmi模块和pywin32模块,安装pip的可以直接pip模式安装,很方便。import wmiprint('正在修改IP,请稍候...')wmiService = wmi.WMI()colNicConfigs = wmiService.Win32_N...原创 2019-06-27 13:11:19 · 2997 阅读 · 1 评论 -
磁盘信息 object 通过object.name调用
import wmihardware = open('C:\\Users\\Administrator\\Desktop\\text\\Hardware.txt', 'w')w = wmi.WMI()hardware.write("cpu type,main frequency:\n")for processor in w.Win32_Processor(): hardwa...原创 2019-06-26 22:43:26 · 239 阅读 · 0 评论 -
思考:pip安装python库后在pycharm中没有该库的问题
打开win+r打开cmd命令行,python①查询执行文件路径importsyssys.executable②pycharm设置以上几步操作应该就能解决了原创 2019-06-26 22:38:49 · 1395 阅读 · 1 评论 -
os模块常用函数
#同样,运行后重新打开文件查看变化import os'''with open ('C:\\Users\\Administrator\\Desktop\\text\\kk.txt','r') as f: lines = f.readlines()with open('C:\\Users\\Administrator\\Desktop\\text\\test_new.txt','w...原创 2019-06-26 17:32:17 · 599 阅读 · 0 评论 -
time模块
import timeprint(time.time())#Python time time() 返回当前时间的时间戳(1970纪元后经过的浮点秒数)#>>>1561526498.1335661print (time.localtime())#Python time localtime() 函数类似gmtime(),作用是格式化时间戳为本地的时间。 如果sec参数未输...原创 2019-06-26 14:28:50 · 1865 阅读 · 0 评论 -
CSV模块
读取import csvwith open("test.csv",newline = '') as f: reader = csv.reader(f) #使用csv的reader()方法,创建一个reader对象 for row in reader: #遍历reader对象的每一行 print(row)print("读取完毕!")...原创 2019-06-26 11:26:01 · 485 阅读 · 0 评论 -
random模块函数用法
import random # 调用random模块a = random.random() # 随机从0-1之间抽取一个小数print(a)a = random.randint(0,100) # 随机从0-100之间抽取一个数字print(a)a = random.choice('abcdefg') # 随机从字符串/列表/字典等对象中抽取一个元素(可能会重复)print...原创 2019-06-26 10:34:25 · 804 阅读 · 0 评论 -
模块
使用自己的模块:import xxx#导入xxx模块import xxx as x #导入模块,后面以名字x来使用from xxx import x,y #从xxx模块中导入x和y,后面可以直接使用x,y,不用写成xxx.y这样形式来调用from xxx import *#直接导入模块中的所有内容if __name__ == '__main__'使用他人的模块:第三...原创 2019-06-26 10:33:42 · 225 阅读 · 0 评论 -
复制图片,不用os和shutil模块
with open('C:\\Users\\Administrator\\Desktop\\text\\鲁班软件近期会议.png','rb') as pic1:#图片是二进制,所以用rb读取 a=pic1.read()#读取with open('C:\\Users\\Administrator\\Desktop\\text\\鲁班软件近期会议2.png','wb') as pic2...原创 2019-06-25 18:52:58 · 149 阅读 · 0 评论 -
读取写入文件
file1=open('C:\\Users\\Administrator\\Desktop\\text\\成绩.txt','w+',encoding='gbk')file1.write('''罗恩 23 35 44哈利 60 77 68 88 90马赫 97 99 89 91 95 99妈富尔 100 85 90''')file1.close()file1=open('C:\\Use...原创 2019-06-25 09:42:56 · 254 阅读 · 0 评论 -
python CSV模块练习,字典value函数与items函数
通过风变程序,做的小项目练习,一点点进步,一点点来关于cvs的简单用法,可以看这里https://www.cnblogs.com/unnameable/p/7366437.html主要是向csv中输入一些字典数据import csv#调用csv模块with open('C:\\python\\assets.csv', 'a', newline='') as csvf...原创 2019-07-04 22:28:27 · 1562 阅读 · 0 评论