1 Star 0 Fork 0

jeremyceng / small_python_project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
my_python.py 3.65 KB
一键复制 编辑 原始数据 按行查看 历史
JeremyZeng 提交于 2021-08-27 17:05 . add some documents
print("hello")
print(100+300)
a = 100+500
print(a)
name = "mame" + "shit"
print(name)
n = 123
f = 456.789
s1 = 'Hello, world'
s2 = 'Hello, \'Adam\''
s3 = 'Hello, "Bart"'
s4 = 'Hello,Lisa!'
print(n)
print(f)
print(s1)
print(s2)
print(s3)
print(s4)
print("*************************************************")
age = 3
if age >= 18:
print('your age is', age)
print('adult')
else:
print('your age is', age)
print('teenager')
for x in range(10):
print(x)
x = 0
while x < 10:
print(x)
x += 1
a = {11: 95, 22: 75, 'Tracy': 85}
print(a[11])
print(a['Tracy'])
print(a)
print("*************************************************")
test_str = 'EFR32MG21A010F512IM32'
print(test_str)
new_str = ''.join(filter(str.isdigit, test_str))
print(new_str)
print("*************************************************")
#import os
#import time
#
#result = os.popen("adb shell wm size")
#s = result.read()
#print ("return:" + s)
#s = s[15:-1]
#w = int(s[0:4])
#h = int(s[5:9])
#print ("return:" + s)
#print ("w:",w)
#print ("h:",h)
#time.sleep(1)
#
#PRESS_HOME = "adb shell input keyevent 3"
##os.popen(PRESS_HOME)
#time.sleep(1)
#
#SWIPE_RIGHT = "adb shell input swipe " + str(int(w/4)) + ' ' + str(int(h/2)) + ' ' + str(int(3*w/4)) + ' ' + str(int(h/2))
#print(SWIPE_RIGHT)
#os.popen(SWIPE_RIGHT)
#time.sleep(1)
#
#SWIPE_LEFT = "adb shell input swipe " + str(int(3*w/4)) + ' ' + str(int(h/2)) + ' ' + str(int(w/4)) + ' ' + str(int(h/2))
#print(SWIPE_LEFT)
#os.popen(SWIPE_LEFT)
#time.sleep(1)
#fp = open('C:\\python\\test.txt')
#fp = open('C:/python/test.txt')
#fp = open('test.txt')
#fp = open('C:/python/project_define.h')
#print(fp.read())
#l = fp.readlines()
#for line in l:
# if 'PROJECT_USE_LEDVANCE_DEFINE_ENALBLED' in line:
# print("ssdddd")
# fp.write(line)
##t = t.replace('PROJECT_USE_LEDVANCE_DEFINE_ENALBLED true',
##'PROJECT_USE_LEDVANCE_DEFINE_ENALBLED fales')
#t = fp.read()
#print(fp.read())
#TXTtemp = open("C:\\python\\project_define.h","r+")
#txtbuffer=TXTtemp.read()
##i=0
#oldlist=['']
#newlist=['']
##for txtchar in txtbuffer:
## oldlist.append(txtchar)
## i=i+1
#oldlist=list(txtbuffer)
#print(oldlist)
#for index in range(len(txtbuffer)):
# if oldlist[index]=="PROJECT_USE_LEDVANCE_DEFINE_ENALBLED":
# for j in range(100):
# if oldlist[index+j]=="#if":
# newlist.append("aaaaaa")
# newlist.append("\n")
# j=0
# break
# newlist.append(oldlist[index+j])
#print(newlist)
#strlist="".join(newlist)
#txtnew=open("newtxt.txt","w")
#txtnew.write(strlist)
#txtnew.close()
#TXTtemp.close()
def find_by_index(src_str, index_str, end_str):
src_str = src_str.replace('\t', '')
src_str = src_str.replace(' ', '')
len1 = src_str.find(index_str)
len2 = src_str.find(end_str, len1)
ret = src_str[len1+len(index_str) : len2]
print("find_by_index: "+index_str+" ---> "+ ret)
return ret
def conver_str(src_str, step):
list_l = []
i = len(src_str)
while i > 0:
# print(i)
list_l.append(src_str[i-step:i])
i -= step
# print(list_l)
s = "".join(list_l)
# print("conver_str: " + s)
return s
config_o = open('C:\\python\\small_python_project\\test.txt').read()
config_o = config_o.replace(" ", "")
config_o = config_o.split("\n")
i = 0;
for line in config_o:
if line.find("LEDVANCE_ALL_PRODUCTS") != -1:
print(i)
print(line)
print("-----------------------")
i += 1
config_o = open('C:\\python\\small_python_project\\test.txt').read()
find_s = find_by_index(config_o, "PROJECT_FIRMWARE_VERSION", "\n")
print(find_s)
s = "0123456789"
print(conver_str(s,2))
config_o = open('C:\\python\\small_python_project\\program_log.txt').read()
config_o = config_o.replace("\t", " ")
config_o = config_o.split(" ")
for line in config_o:
if len(line) == 16:
print(conver_str(line, 2))
Python
1
https://gitee.com/jeremyceng/small_python_project.git
git@gitee.com:jeremyceng/small_python_project.git
jeremyceng
small_python_project
small_python_project
master

搜索帮助