python
文章平均质量分 79
alex_mianmian
这个作者很懒,什么都没留下…
展开
-
Use Python and Sed create simple C code
My Simple code is:switch(event){case EVENT_XXXX: name = "EVENT_XXXX"; break;}And all the events are defined on a web page as:<td class="tg-cly1">EVENT_XXXX(OtaStateId, OK/FAIL)</td><td class="原创 2020-11-24 22:23:49 · 110 阅读 · 0 评论 -
count registers in C code -- registers has one pattern
#!/bin/pythonimport osimport rewords_dict={}def grep_reg(key,path): cmd="grep "+key+" -r "+path+" > alex.txt" print cmd os.system(cmd)def match_reg(f,key): ...原创 2019-06-21 10:55:51 · 147 阅读 · 0 评论 -
C language calls python on ubuntu
C code file 1 : c-call-python.c#include "c-call-python.h"PyObject* c_call_py_init(char* path,char* file){ PyObject *pName, *pModule=NULL; Py_Initialize(); PySys_SetPath(path); // path to...原创 2019-05-16 21:55:21 · 114 阅读 · 0 评论 -
develop PCI device by python on QEMU ARM model
QEMU devices are developed by C. I hope to develop a PCI device by python. So PCI device is half C and half python. C part is interface to QEMU, python part is device self. And we need call python fun...原创 2019-05-21 12:55:30 · 506 阅读 · 0 评论 -
C language calls python on windows
1. Need install VS20172. Need install python3.73. Add python path into windows environment variable 'path'4. New an empty project5. Add python include path to VSproject at 'Include Directorie...原创 2019-04-29 18:27:56 · 160 阅读 · 0 评论 -
python serial terminal
python libs need to install:1. pyserial2. wxpythonHere is the code of terminal:#!/usr/bin/env python# generated by wxGlade 0.3.1 on Fri Oct 03 23:23:45 2003#from wxPython.wx import *impor...原创 2019-04-24 17:10:58 · 513 阅读 · 0 评论 -
python delete specific string from an original string
step 1. find specific stringstep 2. delete specific string#!/usr/bin/env python#import redef get_specific_string(string,start,end): target_string = start+'.*?'+end+'+' print(target_string)...原创 2019-04-26 15:29:26 · 190 阅读 · 0 评论 -
python get specific string from an original string
The specific string I want to get is begin with '$' and end with more than one '=' , such as '$AA78B=' or '$\\BA\\\\=='.So the regular express should be '\$.*?\=+'. Why '\$'? because '$' is regular ...原创 2019-04-26 14:01:16 · 165 阅读 · 0 评论 -
python script which count words from text
#!/bin/pythonwords_dict={}f=open("count_words.txt","rb")for eachline in f: print eachline line_words = eachline.split() print line_words for word in line_words: if word in words_dict.keys():...原创 2019-01-07 17:03:02 · 125 阅读 · 0 评论 -
Start python script when ubuntu get boot
If we want to start the python script when ubuntu get boot, we need configure ubuntu boot script.Case 1. use ubuntu profile configure1) create a shell script alex_auto.sh at /etc/profile.d/#!/b...原创 2019-01-04 18:49:40 · 154 阅读 · 0 评论 -
Python socket epoll file transfer example
The architecture is:Server side function:1. receive file name and file length, create the file. create new thread to handle the data transfer2. receive file data and write to file.3. close fil...原创 2018-12-11 17:10:50 · 220 阅读 · 0 评论 -
Use python develop web page which can read and write mysql database
1. Python access mysql databaseFirstly we need install mysql python package: MySQLdb>sudo pip install mysql-pythonAnd we need setup MySQL on your computer.Here is the example database table...原创 2018-12-03 14:45:20 · 145 阅读 · 0 评论 -
Use python develop web page which can read and write excel file
The idea comes from school students information collection.This prototype is setup a web page for user to input information and all the information will be saved to the Excel file. it will read the ...原创 2018-09-30 15:02:09 · 199 阅读 · 0 评论