โรงเรียนบัวเชดวิทยา | คิดเป็น ทำเป็น แก้ปัญหาเป็น เพื่อ ...



String ?????? PythonApril 3, 2017?·?1,546 views??????? ????????????????????????? String ?????? Python ??????????????????????????????????? String ????????????? ???????????????????????? String ????????????????? ??????????????????????????????????????????? ?????????????????????? built-in function ?????? Python ?????????????????????????????????? String??????????????? StringString ?????????????????????????????????????? ?????????? Python ?????????????????? String ???????????????????????????? Double quote ???? Single quote ???????? ?????????????????????????????? Stringname = "Mateo"site = ''str1 = "This is my string"str2 = 'This is my string'?????????? ???????????? 4 ????????? String ??????????????????????????????????????????? String literal ???????????????????? Double quote ("") ???? Single quote ('') ???????? ????????????????????????????? ??????? String ??????????????????????????????? String???????????? ???????????????????? Double quote ???? Single quote ??? String ??? ??????????????????????????????????????????????????????????????????????????????? String ???????????? Escape character ???????????????????????sentent1 = "What's your name?"sentent2 = 'I\'m Mateo.'sentent3 = "He said \"I would learn Python first\"."sentent4 = 'His teach replied "Oh well!"'print(sentent1)print(sentent2)print(sentent3)print(sentent4)?????????? ?????????????????????????????? String ????????????? Escape character ?????????????'?????"????????? Escape character ?????????????????????????????????? ??????????????????????\????????????????? ????????? Python ??????????? Double quote ??????????? String ??????????????? Escape character ?????? Single quote ???????????????What's your name?I'm Mateo.He said "I would learn Python first".His teach replied "Oh well!"????????????????????????????????????????????????????????????????????? Double quote ??? Single quoteraw_str = r"Python\tJava\tPHP\n"print(raw_str)?????? Python ??????????????????????????????? String ????????????????? raw string ???????????????? ???????????????r?????????????????????'??????"????? raw string ??????????? String ?????????????????????? String literal ????????????? ?????????????????? String ???????????????? ??????????????????????????"""??????'''?String literal ????????????????????????????????? raw string ?????????? Escape ???????????? ????????????str = """\HTTP response code 200 Success 404 Not found 503 Service unavailable """print(str)?????????? ??????????????????? String ??????????????????? String literal ???????????????????????????"""..."""???????????????????????????????? String ????????? ????????????????? Newline ?????????????????????? ???????????????????????????????\???????? Newline ???????? ????????????????????????HTTP response code 200 Success 404 Not found 503 Service unavailable String concatenation??????????????????????? ?????? Python ???????????????????????????? String ?????????????? ??????????????????????? (+) ???????????????????????????????????????????????????????????????????? ?????????????????? String ?????????????????? String ???????????????????????????Operator overloading????????????????????????? Stringfirst_name = 'Matt'last_name = 'Williams'full_name = first_name + ' ' + last_namebless = 'Merry' + 'Christmas!'print(full_name)print(bless)?????????? ???????????????? String ?????? Python ????????????first_name??????????????? ??????????last_name?????????????????? ??????????????????full_name????????????????????????????? String ?????????????????????????????????????? ???????????????????? String ????????? ????????????bless???????????????????? String literal ????????????????????????????????????? ????????????????????????????????Matt WilliamsMerryChristmas!?????? Python ????????????????????? String ?????????????????? ???? White-space Tab ???? Newline ??? String literal ??????????????????????????????????????????????????????????????????????????? ??????????????????????????? String ????????????????????????????\???????????????????????????????????????????? ????????????name = 'Matt' 'Williams'my_number = 'One '\'Two '\'Three 'print(name)print(my_number)?????????? ???????????????? String ????????????????????????????????????? ???????????????????? ?????????????????????????????????????? + ????????????????????????????????????????????? ???????????? ????????????????????????? ???????????????????????????MattWilliamsOne Two Three ?????????????????????????????????????????????? String ???????????Charterers of string????????? String ???????????????????????? ??????????????????? String ????????????????????????? String ???????????????????? ?????????????????????????????????????????????? ??? String ?????????? Index ?????? ?????????????????????????????? List ????????????s = 'Mountain'print(s[0]) # Mprint(s[4]) # tprint(s[7]) # n?????????? ???????????????????????????????????????? String?s??????????????????????????? Index ??????????????[]??????? Index ??? String ?????????????? 0 ???????????????? ???????????????? 1 ?????????????????????s = 'Mountain's[0] = 'a' # invalid???????????? ??????????? String ??????? Index ??????????????????????????????????? ??????????????????????? ??????????????????????????????????????????? ???????????????????????????????????? String ??????? Index ??????s = 'Python'for c in s: print(c)print()s = ''for i in range(len(s)): print('s[%d] = %c' % (i, s[i]))print()????????? String ????????????????????????? ???????????????????????????????? For loop ?????????????? String ???????????? ???????????????? ??????????????????????????????? For ??????????? String ???????????? ?????????????? ???????????? For ????? Index ??????? 0 ???????????????????? String ????????????Pythons[0] = ms[1] = as[2] = rs[3] = cs[4] = us[5] = ss[6] = cs[7] = os[8] = ds[9] = es[10] = .s[11] = cs[12] = os[13] = m????????????????????????????????????????? ?????? Python ????????????????????????? String ???? Index ????????????????????? ????? String ????????????????????? ?????????? Strings1 = 'Mountain'print(s1[0:4]) # Mounprint(s1[4:6]) # taprint(s1[0:1]) # Ms2 = 'marcuscode'print(s2[:6]) #marcusprint(s2[6:]) #code?????????? ???????????????? Index ??????????????????????????????[start:end]????????start??????????????????? Index ?????????????????? ????end??????????????????????????????????????????????????????????? ????????????????????????????????????s1????????????????????????????start???????? ????????????????????????????????????????????? String ???????????????????end???????? ??????????????????????????????????????? String ???????????????s2MountaMmarcuscode??????????????????????????????????????????? String ???? Index???????????? ???????????????????????? String ????????????????????????????? Python ????????????len()??????????????????????????? String ??????? ?????????????????????????? Integer ?????????????????????????????? Strings1 = 'Mountain's2 = 'marcuscode's3 = 'Python'print('length of s1 =', len(s1))print('length of s2 =', len(s2))print('length of s3 =', len(s3))?????????? ???????????????????len()????????????????????????? String ????????? ?????????????????????????? console ???????????????????????????length of s1 = 8length of s2 = 10length of s3 = 6??????? ??????????????????????????????????? String ?????? Python ????????????????????????????????????? ?????????????????? String ??????????? ????????? ??????????????????????????????????????? String ??????? Index ??????????????????????????????????????????? String ????????? ???????????????????????????????????? Python ?????????????? String ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download