This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
# Output example: [======= ] 75% | |
# width defines bar width | |
# percent defines current percentage | |
def progress(width, percent): | |
print "%s %d%%\r" % (('%%-%ds' % width) % (width * percent / 100 * '='), percent), | |
if percent >= 100: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if type(value) == type(None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
a="12345" | |
string.atoi(a) #转整型 | |
b="123.678" | |
string.atof(b) #转浮点数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if os.path.exists("test.log"): | |
os.remove("test.log") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float("%.2f" %value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1.正则 | |
strip("\r\n") #方法2 | |
"".join(s.strip()) #方法3 | |
#方法3的原理 | |
''' | |
Return a list of the words of the string s. | |
If the optional second argument sep is absent or None, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path | |
import time | |
def adbcheck(): | |
if "\tdevice\n" in os.popen("adb devices").read(): | |
print "connected" | |
else: | |
while True: | |
print "phone is not connected,please check phone adb interface!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def judgeactivity(): | |
actinfo =os.popen("adb shell dumpsys activity").readlines() | |
for i in actinfo: | |
if i.find("mFocusedActivity: ActivityRecord") > -1: | |
if i.find(r"com.googlecode.android_scripting/com.example.com") > -1: | |
return True | |
else: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from distutils.core import setup | |
try: | |
from distutils.command.build_py import build_py_2to3 as build_py | |
except ImportError: | |
# 2.x | |
from distutils.command.build_py import build_py |
OlderNewer