搜索到与相关的文章
Python

Python字符串大小写转换拼接删除空白

1.字符串大小写转换string.title()#将字符串中所有单词的首字母以大写形式显示string.upper()#将字符串中所有字母转化为大写字母string.lower()#将字符串中所有字母转化为小写字母str="helloworld!"print(str.title())HelloWorld!print(str.upper())HELLOWORLD!print(str.lower())helloworld!2.字符拼接python中只用使用'+

系统 2019-09-27 17:50:30 1924

Python

php调用python服务

php调用python服务侃侃:公司用的php的popen以命令的形式调用python,首先说说这样做的缺点。php执行命令行调用python的缺点popen('pythontest.py[参数]','r');缺点一:windows默认的是gbk编码,当php中传utf-8中文参数的时候,python接收到的参数会有问题。当然,这是有解决的办法的,就是windows下转换一下字符的编码,linux不用转换。再来python接收参数的时候肯定也要转换编码了,

系统 2019-09-27 17:50:10 1924

Python

centos python3.4更新到3.6

centospython3.4更新到3.6python3.4是yum安装的就直接执行命令:yumupdatepython34-y如果是通过源码安装的,就需要下3.6源码包,重新解压,编译,安装

系统 2019-09-27 17:50:00 1924

Python

萌新用Python尝试爬豆瓣top250

这是我在CSDN的第一篇博客,假期刚自学Python,尝试爬取了一下豆瓣top250.希望可以有大佬指点感谢importrequestsfrombs4importBeautifulSoupdefgethtml(url):try:kv={'user-agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/59.0.3071.115Safari/

系统 2019-09-27 17:49:53 1924

Python

Python实现微信中找回好友、群聊用户撤回的消息功能示例

本文实例讲述了Python实现微信中找回好友、群聊用户撤回的消息功能。分享给大家供大家参考,具体如下:还在好奇好友撤回了什么消息吗?群里撤回了什么消息?下面的代码实现了:即使群、好友撤回了文本消息、表情、图片等消息,自己也能知道撤回的什么。#coding=utf-8importitchatfromitchat.contentimportTEXTfromitchat.contentimport*importsysimporttimeimportreimpor

系统 2019-09-27 17:49:48 1924

Python

猜数字游戏_Python

预先设置数字变量age_of_test=25#这里设置为25,也可随意guess_age=int(input("guessage:"))ifguess_age==age_of_test:print("Yes,yougotit!")#判断正确后打印Yes,yougotit!并继续执行命令elifguess_age>age_of_test:print("thinksmaller...")#判断数字小于预定值时提示!else:print("thinkbigger

系统 2019-09-27 17:49:37 1924

Python

python多进程间通信

这里使用pipe代码如下:importtimefrommultiprocessingimportProcessimportmultiprocessingclassD:@staticmethoddeftest(pipe):whileTrue:foriinrange(10):pipe.send(i)time.sleep(2)@staticmethoddeftest2(pipe):whileTrue:print('test2value:%s'%pipe.recv

系统 2019-09-27 17:49:29 1924

Python

Python学习笔记之文件的读写操作实例分析

本文实例讲述了Python文件的读写操作。分享给大家供大家参考,具体如下:读写文件读取文件f=open('my_path/my_file.txt','r')#open方法会返回文件对象file_data=f.read()#通过read方法获取数据f.close()#关闭该文件首先使用内置函数open打开文件。需要文件路径字符串。open函数会返回文件对象,它是一个Python对象,Python通过该对象与文件本身交互。在此示例中,我们将此对象赋值给变量f。

系统 2019-09-27 17:49:16 1924

Python

Python thread demo

frommultiprocessingimportProcess,Queuefromtimeimporttimedeftask_handler(current_list,result_queue):total=0fornincurrent_list:total+=nresult_queue.put(total)defmain():processes=[]number_list=[xforxinrange(1,10000001)]result_queue=Q

系统 2019-09-27 17:48:29 1924

Python

python如何读取bin文件并下发串口

下面是实现代码#coding:utf-8importtime,serialfromstructimport*importbinasciifile=open('E:\\1.bin','rb')i=0while1:c=file.read(1)#将字节转换成16进制;ssss=str(binascii.b2a_hex(c))[2:-1]print(str(binascii.b2a_hex(c))[2:-1])ifnotc:breakser=serial.Seri

系统 2019-09-27 17:48:02 1924