File: string_startswith.py

package info (click to toggle)
micropython 1.26.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 50,196 kB
  • sloc: ansic: 324,551; python: 63,215; xml: 4,241; makefile: 3,618; sh: 1,586; javascript: 754; asm: 723; cpp: 83; exp: 11; pascal: 6
file content (35 lines) | stat: -rw-r--r-- 1,051 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
print("foobar".startswith("foo"))
print("foobar".startswith("Foo"))
print("foobar".startswith("foo1"))
print("foobar".startswith("foobar"))
print("foobar".startswith(""))

print("1foobar".startswith("foo", 1))
print("1foo".startswith("foo", 1))
print("1foo".startswith("1foo", 1))
print("1fo".startswith("foo", 1))
print("1fo".startswith("foo", 10))

print("1foobar".startswith("foo", 1, 5))
print("1foobar".startswith("foo", 1, 4))
print("1foobar".startswith("foo", 1, 3))
print("1foobar".startswith("oo", 2, 4))
print("1foobar".startswith("o", 3, 4))
print("1foobar".startswith("o", 4, 4))
print("1foobar".startswith("o", 5, 4))

print("foobar".startswith("foo", None, None))
print("foobar".startswith("foo", None, 3))
print("foobar".startswith("foo", None, 2))
print("foobar".startswith("bar", 3, None))


print("foobar".startswith(("foo", "sth")))
print("foobar".startswith(("sth", "foo")))
print("foobar".startswith(("sth", "foo2")))
print("foobar".startswith(("foo", )))

try:
    "foobar".startswith(1)
except TypeError:
    print("TypeError")