python formatted output, the output cycle

python formatted output, encoding cycle

  • pycharm installation and use
    • Supporting the development of software, code line by line debugging, set the high-end, you will not, and are not prompted to debug mode at the time of writing the code, the best thing pycharm
  • Formatted output
    • When you come across such a demand: the string you want some locations can be passed into a dynamic, first of all think of formatted output.
      Name = the INPUT ( 'Please enter the name:')
      Age = the INPUT ( 'Please enter Age: ')
      Job = iNPUT (' enter Job: ')
      Hobby = iNPUT (' enter interested: ')
      MSG =' '' ----- ----------------------- info of% S -------
      the Name:% S
      Age:% S
      Job:% S
      Hobby:% S
      ------------ -------------- End --- '' '% (name, name, Age, Job, Hobby)
      Print (MSG)

        在格式化输出中,如果只想表示一个"%",并不是一个占位符,只需要再加一个%

      msg = 'My name is% s, year% s, d %% learning progress%'% ( 'Taibai', '18', 1)
      Print (msg)

  • while loop
    • Infinite loop (loop can be terminated)
      • Changing conditions (flags, set up the number of cycles)
      • break (out of the whole cycle)
      • continue (out of the inner loop, this loop continues out of the next cycle)
        COUNT = 0
        In Flag = True
        the while In Flag:
        COUNT = +. 1
        Print (COUNT)
        IF COUNT == 100:
        In Flag = False
    • Finite loop (setting condition)
      COUNT = 0
      the while COUNT <100:
      COUNT = +. 1
      Print (COUNT)

    • while,else
      • As long as the while loop is normal (not being interrupted by the break), else statement a normal print
        while loop is interrupted if the break, else statements are executed.
        COUNT = 0
        while COUNT <. 5:
        COUNT = +. 1
        IF COUNT = . 3 =:
        BREAK
        Print (COUNT)
        the else:
        Print (666666)
    Operators
    • Arithmetic operators (+, -)
    • Comparison operators (>, <, =)
    • Assignment operator (=)
    • Logical operators (not, and, or)
      • In the absence (), the order of operations not> and> or, the same priority is calculated sequentially from left to right
        • Case 1: the operational sides are relatively
          print (2> 1and 3 <4 or 4> 5 and 2 <1)
        • Case 2: Both sides are integers
          x or y, x is true, the value of x, x is false, the value of Y
          Print (. 1 or 2)
          Print (or 2. 3)
          Print (-1 or 2)
          Print (0. 1 or )
          questions:
          Print (1> 2 and 3 or 6)
          results: 6
          (False or 1) output 1
            (1 or False) output 1
          (True or 1) output of the former
            (1 or True) output of the former
          (True and 1 ) which outputs
            (1 and True) which outputs
          (False and 1) output False

Encoded acquaintance

  • Ascii code: only contain letters, numbers, special characters; a total of eight, leftmost bit is 0; a character represents a byte
  • GBK: contain letters, numbers, special characters and Chinese. GB. One of the numbers, letters, special characters represents one byte; two bytes representative of a Chinese character
  • Unicode code (Unicode): contains all the text in the world; the beginning of a character is represented by two bytes, but it does not contain all of the text, the latter for Unicode UTF-8 is an upgrade
  • UTF-8: Minimum represented by eight bits (one byte) characters, European characters with two bytes, three bytes Chinese.

'China 12he': GBK: 8 bytes

'China 12he': UTF-8: 10 bytes

8bit = 1byte
1024byte = 1KB
1024KB = 1MB
1024MB = 1GB
1024GB = 1TB
1024TB = 1PB
1024TB = 1EB
1024EB = 1ZB
1024ZB = 1YB
1024YB = 1NB
1024NB = 1DB

Guess you like

Origin www.cnblogs.com/940531gbh/p/11263896.html