You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
@echo off
cd C:\Temp
REM Aktuelles Verzeichnis in einer Variable setzen
SET mydir="Mein Verzeichnis lautet %CD%"
echo %mydir%
REM "Mein Verzeichnis lautet C:\Temp"
184
Batch
Filehandling
Prüfen ob Datei existiert
@echo off
SET checkFileExists="C:\Temp\myFile.txt"
IF exist %checkFileExists% GOTO :EXISTS
GOTO :EXISTSNOT
:EXISTS
echo There it is :-)
GOTO :END
:EXISTSNOT
echo Sorry, the file isn't there :-(
GOTO :END
:END
echo End of program
185
T-SQL
Strings
Prüfen ob eine Zahl in einem String enthalten ist
SELECT
value
,CASE
WHEN PATINDEX('%[0-9]%',value) > 0 THEN 1
ELSE 0
END AS CheckIfStringContainsANumber
FROM
(
SELECT 'String w/o a number' AS value
UNION ALL
SELECT 'This string contains 1 as a number' AS value
) subQuery1
-- value | CheckIfStringContainsANumber
-- ------------------------------------------------------------------
-- String w/o a number | 0
-- This string contains 1 as a number | 1
186
Python
Strings
String nach Delimenter zerlegen
myString = "A;B;C;D;E"
myPieces = myString.split(";") # erzeugt ein Arrey mit den einzelnen Zeichen
print myPieces[2] # gibt C aus
def this_is_my_function_name(param1):
print "do something inside the function " + param1
print "do something outside the function"
# call the function
this_is_my_function_name("hello world")
189
Python
Schleifen
For-Schleife
for i in range(0, 10):
i=1
time.sleep(1)
print i
items = ['computer', 'fruits', 'fraggels']
# without indexes
for item in items:
print item
# with indexes
for (i, item) in enumerate(items):
print i, item
190
Python
Schleifen
While Schleife
i=10
while i<10:
i=i+1
print i
191
Python
Encoding / Decoding
md5-Hash erzeugen
# https://docs.python.org/2/library/hashlib.html
import hashlib
a = "hello world"
b = 0.1
md5str = hashlib.md5(str(b) + a).hexdigest()
192
Python
Filehandling
Prüfen ob Datei existiert
import os
filePath="/home/myUser/test.txt"
if (os.path.isfile(filePath)):
print "There it is! ;-)"
else:
print "Whow, file is missing at this place :-("