python
wgz7747147820
这个作者很懒,什么都没留下…
展开
-
linux安装python3.7.3
从www.python.org下载源码包 三步安装 ./configure make make install make install碰到这个问题 ModuleNotFoundError: No module named ‘_ctypes’ 需要安装依赖包 yum -y groupinstall "Development tools" yum -y install zlib-devel b...原创 2019-05-30 22:19:30 · 1054 阅读 · 0 评论 -
python的fork进程后子进程一定要退出
[root@linux1 python_tidb]# cat mypy03.py #!/usr/bin/env python3 import os def fork_process(): newpid=os.fork() if newpid==0: pid=os.getpid() cmd = 'python3 mypy02.py '+str(pid...原创 2019-06-07 23:34:54 · 2141 阅读 · 0 评论 -
我的第一个python线程小程序
[root@linux1 python_tidb]# cat ./mypy02.py #!/usr/bin/env python3 import pymysql,sys,os import _thread,time def child(tid): print("_thread id %s" % tid) time.sleep(50) print("end _thread ...原创 2019-06-08 07:52:42 · 168 阅读 · 0 评论 -
python3线程加锁的一个例子
再这个例子中,线程加上锁之后有并行变成了实际上的串行 [root@linux1 python_tidb]# cat mypy02.py #!/usr/bin/env python3 import pymysql,sys,os import _thread,time def counter(myid,count): mutex.acquire() for i in range(co...原创 2019-06-08 16:47:35 · 2073 阅读 · 0 评论 -
python random模块的一些例子
[root@linux1 python_tidb]# cat mypy02.py #!/usr/bin/env python3 import pymysql,sys,os,string import _thread,time,random print('*'*10) for i in range(5): rand_choice = random.choice(string.ascii_l...原创 2019-06-08 18:27:36 · 457 阅读 · 0 评论 -
python多线程 threading的一个例子
使用threading,主线程不需要等待所有的线程结束就可以退出 [root@linux1 python_tidb]# cat mypy02.py #!/usr/bin/env python3 import pymysql,sys,os,string import _thread,time,random import threading class myThread(threading.Thre...原创 2019-06-08 19:18:59 · 242 阅读 · 0 评论 -
Python3 * 和 ** 运算符
https://blog.csdn.net/yilovexing/article/details/80577510 参考一下 不错转载 2019-06-04 11:04:04 · 573 阅读 · 0 评论 -
python format函数
http://www.runoob.com/python/att-string-format.html 参考一下 不错转载 2019-06-04 11:04:54 · 106 阅读 · 0 评论 -
python open函数名字冲突
在脚本中本意是调用python的内建函数open打开一个文件,结果调用了os.open,所以报错了,应该尽量避免使用from import [crsusr@rws1270149 python_study]$ cat mypy02.py #!/usr/bin/python3.7 #import sys,string,os from os import * f = open('ee.txt','w'...原创 2019-06-04 14:36:41 · 622 阅读 · 0 评论 -
Python使用tkinter界面编程中对话框样式汇总
https://baijiahao.baidu.com/s?id=1635391447350076769&wfr=spider&for=pc 参考一下转载 2019-06-16 18:45:02 · 1310 阅读 · 0 评论 -
python中__import__与import的区别
https://blog.csdn.net/u011502243/article/details/83929085 参考一下转载 2019-06-17 10:40:00 · 969 阅读 · 0 评论 -
python中yield的用法详解——最简单,最清晰的解释
https://blog.csdn.net/mieleizhi0522/article/details/82142856 参考一下 写的不错转载 2019-06-13 15:35:58 · 207 阅读 · 0 评论 -
python3 连接mysql
首先需要安装pymysql 模块 [root@rws1270149 /]# pip3 install pymysql Collecting pymysql Downloading https://files.pythonhosted.org/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/P...原创 2019-06-07 12:08:34 · 3563 阅读 · 1 评论 -
perl和python的读写文件例子
[crsusr@linux2 python_tidb]$ cat mypy01.py #!/usr/local/bin/python3 import glob,sys F = open('samp_python.txt','w') #sys.stdin = F F.write('first line\n') F.write('second line\n') F.write('third lin...原创 2019-05-30 22:40:11 · 250 阅读 · 0 评论 -
python的shelve示例
[crsusr@linux2 python_tidb]$ cat mypy01.py #!/usr/local/bin/python3 import glob,sys,shelve file_shelve = shelve.open('file_shelve') file_shelve['wangming']={'name':'wangming','sex':'male','age':44,...原创 2019-05-30 23:02:53 · 190 阅读 · 0 评论 -
python的类的一个简单例子
[crsusr@linux2 python_tidb]$ cat mypy01.py #!/usr/local/bin/python3 import glob,sys,shelve class person: def __init__(self,v_name,v_age,v_salary=0,v_job='none'): self.name=v_name ...原创 2019-05-31 06:13:01 · 926 阅读 · 0 评论 -
python的字典与perl的hash的对比
[crsusr@rws1270149 python_study]$ cat mypy.py #!/usr/bin/python3.7 #字典实例 python的字典等同于perl的hash dict1 = dict(name='wang fang',age=42,salary=400000) #perl hash的下标用的是{},python的下标无论是列表还是字典都使用的是[]中括号 pr...原创 2019-05-29 10:35:37 · 1178 阅读 · 0 评论 -
perl和python的数据类型对比
perl的数据类型有 1.标量(标量是包括数字、字符串、日期等,但perl没有细分这些字符串),标量声明的时候用$标识 my $var_a = '3'; 2.数组,perl的数组是用@标识的,一个变量前面有@标识这是个数组 my @array_1 = ('wang','tian','zhong',3); 3.hash hash标识是用% my %hash_1 = ('wang','WANG','...原创 2019-05-29 10:56:25 · 322 阅读 · 0 评论 -
python的print语句的分隔符和结束符
>>> print("zhong","guo","ren",sep=":::",end="!!\n"); zhong:::guo:::ren!!原创 2019-05-29 16:45:56 · 10187 阅读 · 0 评论 -
python的map函数和lambda函数
map函数的功能是根据提供的函数对指定序列做映射,就是对第二个参数的每一个值运行第一个参数所指定的函数 lambda是定义一个匿名函数 [crsusr@rws1270149 python_study]$ cat mypy02.py #!/usr/bin/python3.7 #import sys,string,os #from os import * def square(x): ret...原创 2019-06-07 07:29:34 · 1061 阅读 · 0 评论 -
测试python的fork进程的小程序
[crsusr@rws1270149 python_study]$ cat mypy02.py #!/usr/bin/python3.7 import sys,string,os,glob,time #from os import * def parent(): pid = os.fork() if pid == 0: print("from child",os...原创 2019-06-07 09:11:30 · 150 阅读 · 0 评论 -
Python的模块引用和查找路径 讲的很不错
Python的模块引用和查找路径 https://www.cnblogs.com/qingspace/p/5284480.html 讲的很清楚的一篇文章转载 2019-06-07 12:00:18 · 404 阅读 · 0 评论 -
查看python当前安装的所有模块的方法
>>> help() Welcome to Python 3.7's help utility! If this is your first time using Python, you should definitely check out the tutorial on the Internet at https://docs.python.org/3.7/tutoria...原创 2019-06-07 12:04:51 · 9230 阅读 · 1 评论 -
Python中的eval exec及其相关函数
https://www.cnblogs.com/yyds/p/6276746.html 参考一下 不错转载 2019-06-17 11:29:43 · 127 阅读 · 0 评论
分享