本文整理汇总了Python中string.lower函数的典型用法代码示例。如果您正苦于以下问题:Python lower函数的具体用法?Python lower怎么用?Python lower使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lower函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: coards2year
def coards2year(time_in, timestringIn):
""" coards2year(time_in, timestringIn) assume a numpy array for time_in,
and a string of the sort 'hours since 1950-01-01 00:00:00.0' or the like for timestringIn"""
import string
import re
ntim = time_in.shape[0]
time_out = np.zeros([ntim])
stringwords = string.split(timestringIn)
units = stringwords[0]
datestartstring = stringwords[2]
timestartstring = stringwords[3]
### strip off any fractions of a second
timestartstring_split = re.split('\.', timestartstring)
datetimestartstring = datestartstring + ' ' + timestartstring_split[0]
datetimestart = string2datetime(datetimestartstring)
if string.lower(units) == 'hours':
for i in range(0,ntim):
thedays = int(time_in[i])/24
thehours = int(time_in[i])%24
offsettime = datetime.timedelta(hours=thehours, days=thedays)
newtime = datetimestart + offsettime
time_out[i] = date2decimalyear(newtime)
elif string.lower(units) == 'days':
for i in range(0,ntim):
offsettime = datetime.timedelta(days=time_in[i])
newtime = datetimestart + offsettime
time_out[i] = date2decimalyear(newtime)
return time_out
开发者ID:zhenkunl,项目名称:ckplotlib,代码行数:29,代码来源:calendar_funcs.py
示例2: handle_starttag
def handle_starttag(self, tag, attrs):
if tag == "meta":
# look for encoding directives
http_equiv = content = None
for k, v in attrs:
if k == "http-equiv":
http_equiv = string.lower(v)
elif k == "content":
content = v
if http_equiv == "content-type" and content:
# use mimetools to parse the http header
header = mimetools.Message(
io.StringIO("%s: %s\n\n" % (http_equiv, content))
)
encoding = header.getparam("charset")
if encoding:
self.encoding = encoding
if tag in AUTOCLOSE:
if self.__stack and self.__stack[-1] == tag:
self.handle_endtag(tag)
self.__stack.append(tag)
attrib = {}
if attrs:
for k, v in attrs:
attrib[string.lower(k)] = v
self.__builder.start(tag, attrib)
if tag in IGNOREEND:
self.__stack.pop()
self.__builder.end(tag)
开发者ID:AlexStef,项目名称:stef-sublime-conf,代码行数:29,代码来源:HTMLTreeBuilder.py
示例3: search_subtitles
def search_subtitles(file_original_path, title, tvshow, year, season, episode, set_temp, rar, lang1, lang2, lang3, stack): #standard input
subtitles_list = []
msg = ""
if not (string.lower(lang1) or string.lower(lang2) or string.lower(lang3)) == "greek":
msg = "Won't work, subtitles.gr is only for Greek subtitles."
return subtitles_list, "", msg #standard output
try:
log( __name__ ,"%s Clean title = %s" % (debug_pretext, title))
premiered = year
title, year = xbmc.getCleanMovieTitle( title )
except:
pass
if len(tvshow) == 0: # Movie
searchstring = "%s (%s)" % (title, premiered)
elif len(tvshow) > 0 and title == tvshow: # Movie not in Library
searchstring = "%s (%#02d%#02d)" % (tvshow, int(season), int(episode))
elif len(tvshow) > 0: # TVShow
searchstring = "%s S%#02dE%#02d" % (tvshow, int(season), int(episode))
else:
searchstring = title
log( __name__ ,"%s Search string = %s" % (debug_pretext, searchstring))
get_subtitles_list(searchstring, "el", "Greek", subtitles_list)
return subtitles_list, "", msg #standard output
开发者ID:SMALLplayer,项目名称:smallplayer-image-creator,代码行数:27,代码来源:service.py
示例4: Read
def Read(self,filename):
"""Read units from file with specified name.
The units file is an ascii file where each line contains a couple of
words separated by a colon and a blank. The first word is the type of
quantity, the second is the unit to be used for this quantity.
Lines starting with '#' are ignored.
A 'problem: system' line sets all units to the corresponding value of
the specified units system.
"""
fil = file(filename,'r')
self.units = {}
for line in fil:
if line[0] == '#':
continue
s = string.split(line)
if len(s) == 2:
key,val = s
key = string.lower(string.rstrip(key,':'))
self.units[key] = val
if key == 'problem':
self.Add(self.Predefined(string.lower(val)))
else:
print "Ignoring line : %s\n",line
fil.close()
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:25,代码来源:units.py
示例5: SuspiciousChk1
def SuspiciousChk1(list_str):
pattern = "C:\\DOCUME~1\\"
pattern = string.lower(pattern)
list_str = string.lower(list_str)
if list_str.find(pattern) >= 0:
return True
return False
开发者ID:npascan,项目名称:OMF,代码行数:7,代码来源:C-C_Analysis.py
示例6: SvchostChk
def SvchostChk(list_str):
pattern = "C:\\WINDOWS\\system32\\svchost.exe"
pattern = string.lower(pattern)
list_str = string.lower(list_str)
if list_str.find(pattern) >= 0:
return True
return False
开发者ID:npascan,项目名称:OMF,代码行数:7,代码来源:C-C_Analysis.py
示例7: vertDimParse
def vertDimParse(entry):
description = 'None'
units = 'None'
verticality = slats.SingleLevel
positive = slats.UpDirection
grib_id = 0
grib_p1 = 0
grib_p2 = 0
grib_p3 = 0
nentry = len(entry)
if nentry>1: description = string.strip(entry[1])
if nentry>2: units = string.strip(entry[2])
if nentry>3:
if string.lower(string.strip(entry[3]))=='single':
verticality = slats.SingleLevel
else:
verticality = slats.MultiLevel
if nentry>4:
if string.lower(string.strip(entry[4]))=='up':
positive = slats.UpDirection
else:
positive = slats.DownDirection
if nentry>5: grib_id = string.atoi(entry[5])
if nentry>6: grib_p1 = string.atoi(entry[6])
if nentry>7: grib_p2 = string.atoi(entry[7])
if nentry>8: grib_p3 = string.atoi(entry[8])
return [description, units, verticality, positive, grib_id, grib_p1, grib_p2, grib_p3]
开发者ID:AZed,项目名称:uvcdat,代码行数:27,代码来源:latsParmTab.py
示例8: download
def download(id, url, filename, search_string=""):
subtitle_list = []
exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass"]
## Cleanup temp dir, we recomend you download/unzip your subs
## in temp folder and pass that to XBMC to copy and activate
if xbmcvfs.exists(__temp__):
shutil.rmtree(__temp__)
xbmcvfs.mkdirs(__temp__)
filename = os.path.join(__temp__, filename + ".zip")
req = urllib2.Request(url, headers={"User-Agent": "Kodi-Addon"})
sub = urllib2.urlopen(req).read()
with open(filename, "wb") as subFile:
subFile.write(sub)
subFile.close()
xbmc.sleep(500)
xbmc.executebuiltin(
(
'XBMC.Extract("%s","%s")' % (filename, __temp__,)
).encode('utf-8'), True)
for file in xbmcvfs.listdir(__temp__)[1]:
file = os.path.join(__temp__, file)
if os.path.splitext(file)[1] in exts:
if search_string and string.find(
string.lower(file),
string.lower(search_string)
) == -1:
continue
log(__name__, "=== returning subtitle file %s" % file)
subtitle_list.append(file)
return subtitle_list
开发者ID:estemendoza,项目名称:service.subtitles.argenteam,代码行数:35,代码来源:service.py
示例9: ExtractSource
def ExtractSource( file ):
from xml.dom.minidom import parse
dom = parse( file )
files = dom.getElementsByTagName( 'File' )
l = []
for i in files:
s = i.getAttribute( 'RelativePath' )
s = s.encode('ascii', 'ignore')
s = re.sub( '\\\\', '/', s )
s = re.sub( '^\./', '', s )
# this is a bit of a hack, and should probably be thought about more.
# if the file is excluded from the Release|win32 config it will be excluded in linux.
# Not necessarily correct, but thats how it will be for now. Could add a linux config
# if we get files that only want to exclude in one and not the other.
exclude = 0
configs = i.getElementsByTagName( 'FileConfiguration')
for thisConfig in configs:
if (string.lower(thisConfig.getAttribute('ExcludedFromBuild')) == 'true' and
string.lower(thisConfig.getAttribute('Name')) == 'release|win32'):
exclude = 1
if (exclude == 0) and (( string.lower( s[-4:] ) == '.cpp' or string.lower( s[-2:] ) == '.c' )):
l.append( s )
return l
开发者ID:DaTa-,项目名称:cnq3x,代码行数:26,代码来源:scons_utils.py
示例10: makeChoice
def makeChoice(choice, pad, alpha):
if choice == "1":
message = lower(raw_input("Enter a message you wish to encrypt, with no spaces\n"))
try:
encryptedMessage = convertMessage(message, pad, alpha)
print "Encrypted message is as follows\n", encryptedMessage
except IndexError:
print "Error: Pad is smaller than message"
elif choice == "2":
message = lower(raw_input("Enter a message you wish to decrypt, with no spaces\n"))
try:
decryptedMessage = deconvertMessage(message, pad, alpha)
print "Decrypted message is as follows\n", decryptedMessage
except IndexError:
print "Error: Pad is smaller than message"
elif choice == "3":
padFile = raw_input("Enter a filename to write to\nWARNING, DO NOT ENTER AN EXISTING TXT FILE: ")
writeOutPad(padFile, pad)
else:
print "Error: selection was not 1, 2 or 3\n\n"
return choice
开发者ID:SCOTPAUL,项目名称:oneTimePad,代码行数:25,代码来源:oneTimePad.py
示例11: index_sort
def index_sort(s1, s2):
if not s1:
return -1
if not s2:
return 1
l1 = len(s1)
l2 = len(s2)
m1 = string.lower(s1)
m2 = string.lower(s2)
for i in range(l1):
if i >= l2 or m1[i] > m2[i]:
return 1
if m1[i] < m2[i]:
return -1
if s1[i] < s2[i]:
return -1
if s1[i] > s2[i]:
return 1
if l2 > l1:
return -1
return 0
开发者ID:Magdno1,项目名称:Arianrhod,代码行数:29,代码来源:utils.py
示例12: query
def query(prompt):
answer = raw_input(prompt + "[Y or N]: ")
answer = string.lower(answer)
while answer[0] != 'y' and answer[0]!= 'n':
answer = raw_input("Invalid response. Please type Y or N: ")
answer = string.lower(answer)
return answer[0] == 'y'
开发者ID:4nthonylin,项目名称:Hons_AI,代码行数:7,代码来源:Animal+Guess.py
示例13: remove_alias
def remove_alias( self, dim_name ):
try:
selected_alias = self.alias_list.getcurselection()[0]
d_name = string.lower( dim_name )
except:
return
d_name = string.lower( dim_name )
if d_name == 'longitude':
cdms.axis.longitude_aliases.remove( selected_alias )
elif d_name == 'latitude':
cdms.axis.latitude_aliases.remove( selected_alias )
elif d_name == 'time':
cdms.axis.time_aliases.remove( selected_alias )
elif d_name == 'level':
cdms.axis.level_aliases.remove( selected_alias )
elif d_name == 'directory':
gui_control.favorite_directories.remove( selected_alias )
elif d_name == 'mybinfiles':
gui_control.favorite_files.remove( selected_alias )
# Update the alias list widget
ret_alias_list = return_alias_list( dim_name )
self.alias_list.setlist( ret_alias_list )
# Update VCDAT's alias list
if d_name not in [ 'directory','mybinfiles']:
update_vcdat_alias_list()
else:
record_bookmarks( d_name )
开发者ID:AZed,项目名称:uvcdat,代码行数:30,代码来源:gui_edit_list.py
示例14: get_encodings
def get_encodings(headers):
content_encoding = transfer_encoding = None
if headers.has_key("content-encoding"):
content_encoding = string.lower(headers["content-encoding"])
if headers.has_key("content-transfer-encoding"):
transfer_encoding = string.lower(headers["content-transfer-encoding"])
return content_encoding, transfer_encoding
开发者ID:MaxMorais,项目名称:Trail,代码行数:7,代码来源:Reader.py
示例15: do_examine
def do_examine( self, s ):
cur_room = self.map.getRooms()[self.player.getPos()]
for item in cur_room.getItems() + cur_room.getDroppedItems():
if string.lower(item.getName()) == string.lower(s):
print self.parser.parseDescription(item.getExamineText())
return
print "You don't see anything that looks like a " + yellow(s) + '.'
开发者ID:jmt4,项目名称:thomp-tbrpg,代码行数:7,代码来源:CmdLine.py
示例16: SuspiciousChk
def SuspiciousChk(list_str):
pattern = "C:\\Documents and Settings\\"
pattern = string.lower(pattern)
list_str = string.lower(list_str)
if list_str.find(pattern) >= 0:
return True
return False
开发者ID:npascan,项目名称:OMF,代码行数:7,代码来源:C-C_Analysis.py
示例17: OnLOSNotify
def OnLOSNotify(self,ID,noHitFlag,sceneobject,hitPoint,distance):
PtDebugPrint("tldnVaporScope:LOSNotify: ID=%d noHitFlag=%d at a distance of %g" % (ID,noHitFlag,distance),level=kDebugDumpLevel)
PtShootBulletFromScreen(self.key,0.5,0.5,1.0,10000)
if sceneobject:
PtDebugPrint("tldnVaporScope:LOSNotify: ===>hit object %s at point(%g,%g,%g)" % (sceneobject.getName(),hitPoint.getX(),hitPoint.getY(),hitPoint.getZ()),level=kDebugDumpLevel)
# first look for a python file guy (before responders)
pmlist = sceneobject.getPythonMods()
if len(pmlist) > 0:
PtDebugPrint("tldnVaporScope:LOSNotify: ...python mod list:",level=kDebugDumpLevel)
for pm in pmlist:
PtDebugPrint(" %s" % (pm.getName()),level=kDebugDumpLevel)
if string.lower(pm.getName()).startswith("vaporminerhitme"):
PtDebugPrint("tldnVaporScope:LOS: VaporMiner HIT!",level=kDebugDumpLevel)
notify = ptNotify(self.key)
notify.clearReceivers()
notify.addReceiver(pm)
notify.setActivate(1.0)
notify.send()
else:
PtDebugPrint("tldnVaporScope:LOSNotify: ...no python mods found",level=kDebugDumpLevel)
# next look for responders attached
resplist = sceneobject.getResponders()
if len(resplist) > 0:
PtDebugPrint("tldnVaporScope:LOSNotify: ...responder list:",level=kDebugDumpLevel)
for resp in resplist:
PtDebugPrint(" %s" % (resp.getName()),level=kDebugDumpLevel)
if string.lower(resp.getName()).startswith("vaporminerhitme"):
PtDebugPrint("tldnVaporScope:LOS: VaporMiner HIT!",level=kDebugDumpLevel)
atResp = ptAttribResponder(42)
atResp.__setvalue__(resp)
atResp.run(self.key)
else:
PtDebugPrint("tldnVaporScope:LOSNotify: ...no responders found",level=kDebugDumpLevel)
else:
PtDebugPrint("tldnVaporScope:LOSNotify: No sceneobject found...",level=kDebugDumpLevel)
开发者ID:AtlantisShard,项目名称:moul-scripts,代码行数:35,代码来源:tldnVaporScope.py
示例18: SuspiciousChk2
def SuspiciousChk2(list_str):
pattern = "C:\\Windows\\System32\\"
pattern = string.lower(pattern)
list_str = string.lower(list_str)
if list_str.find(pattern) >= 0:
return True
return False
开发者ID:npascan,项目名称:OMF,代码行数:7,代码来源:C-C_Analysis.py
示例19: splitArgs
def splitArgs(s, casetype=LOWER_ALL):
res = []
i = 0
n = len(s)
if casetype==LOWER_ALL:
s = string.lower(s)
while i < n:
while i < n and s[i] in string.whitespace: i = i+1
if i == n: break
if s[i] == '"' or s[i] == "'":
quote = s[i]
i = i+1
j = i
while j < n and s[j] != quote: j = j+1
res.append(s[i:j])
i = j+1
else:
j = i
while j < n and s[j] not in string.whitespace: j = j+1
if casetype == LOWER_NON_QUOTED:
res.append(string.lower(s[i:j]))
else:
res.append(s[i:j])
i = j
return res
开发者ID:vinyldarkscratch,项目名称:mudmaker,代码行数:26,代码来源:utils.py
示例20: search
def search(self, pattern='', context=''):
pattern = string.replace(string.lower(pattern),'*','%')
pattern = string.replace(string.lower(pattern),'?','_')
if pattern:
return self.select("context LIKE '%s'" % pattern, orderBy="context")
else:
return self.select(orderBy="context")
开发者ID:BackupTheBerlios,项目名称:esm-svn,代码行数:7,代码来源:Setting.py
注:本文中的string.lower函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论