[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/Dalguring/PythonStudy/master/type/stringType.py [Back]  [Original]

#  
#     
# "", '', """, '''
print("[   ]\n")

print("Hello World")
print('Python is fun')
print("""Life is too short, You need python""")
print('''Life is too short, You need python''')

print("=" * 50)

# "" ''     ,     "  '     """ , '''    .
print("""my friend said, "welcome to python world" """)
print('''It's mine''')

multiline = """Life is too short
You need python"""

print(multiline)

# """  ( )         
multiline = """
Life is too short
You need python
"""

print(multiline)

print("=" * 50)

#     ,        (    )
print("Python's favorite food is perl")
print('"Python is very easy." he says')

print("=" * 50)
print("[   ]\n")
#  
head = "Python"
tail = ' is fun!'

print(head + tail)

a = 'python'
print(a * 2)

print("=" * 50)
print("[   ]\n")

#  ( )
a = "Life is too short"
print(len(a))

a = "Life is too short "
print(len(a))

#  
print(a[3])

if a[-1] == ' ':
    print("")
else:
    print(a[-1])

print("=" * 50)
print("[    ]\n")

#  
a = "Life is too short, You need Python"
b = a[0] + a[1] + a[2] + a[3]

print(b)
print(a[0:4])
print(a[5:])
print(a[:17])
print(a[19:-7])

print("=" * 50)
print("[   ]\n")

#  
print("I eat %s apples" % 3)
print("I eat %s apples" % "five")
print("I ate %d apples. So I was sick for %s days." % (10, "five"))
print("Error is %d%%" % 98)

#  
print("%10sJane" % "hi")
print("%-10sJane" % "hi")
print("{0:10}".format("hi"))
print("{0:^10}".format("hi"))
print("{0:=^10}".format("hi"))
print("{0:!10}")

print("=" * 50)
print("[   ]\n")

# count 
a = "hobby"
print(a.count("b"))

# find 
a = "Python is the best choice"
print(a.find("b"))
print(a.find("k"))

# index 
a = "Life is too short"
print(a.index('t'))
    # print(a.index('k')) -- index        

# join 
print(",".join('abcd'))

# upper 
print("hi".upper())
a = "hI bYe"
print(a.upper())

# lower 
print(a.lower())

# lstrip, rstrip, strip 
a = "{0:^5}".format("hi")
print(a.lstrip())
print(a.rstrip())
print(a.strip())

# replace 
a = "Life is too short"
print(a.replace("Life", "Your leg"))

# split  --   
a = "Life is too short"
print(a.split())
b = "a:b:c:d"
print(b.split(":"))

Web Proxy Viewer  |  New URL  |  Original Page