Chapter 2 Data Types, Character Encodings, File Operations

  • 29 binary conversion;
  • 30 binary conversion (two)
  • 31 Explanation of small exercises on binary conversion
  • 32 ASCII and Binary
  • 33 String encoded fireworks
  • 34 Encodings used in Python
  • 35 Floating point and scientific notation
  • 36 The precision of floating point numbers
  • 37 List types
  • 38 List Types - Modify and Insert
  • 39 List Types - Other Methods
  • 40 List Exercise Questions Explained
  • 41 List of exercises to explain 2
  • 42 shades of copy
  • 43 String Type Explanation
  • 44 String type explanation 2
  • 45 tuple type
  • 46 hash functions
  • 47 Dictionary types and properties
  • 48 Detailed methods of dictionary types
  • 49 Collection types
  • 50 Relational Tests for Collection Types
  • 51 hexadecimal operation
  • 52 Why use hexadecimal
  • 53 Hexadecimal and binary conversion
  • 54 Character Encoding Review
  • How to save 55 characters to the hard disk
  • 56 character encoding conversion
  • 57 Python3 code execution process
  • 58 Python3 code conversion syntax
  • 59 Python3 determines the encoding type by looking at the encoding mapping table
  • 60 Introduction to Python bytes type
  • 61 Difference between Python3 and 2 strings
  • 62 Python3 and 2 encoding summary
  • 63 Job Requirements

29 binary conversion;

1. Introduction - How did humans communicate in ancient times? !

  • flying pigeon biography
  • Eight hundred miles expedited
  • Flare (seems like none)
  • The feudal lords in the beacon show (this is true) the smoke is relatively straight and will not spread

The wolf smoke is relatively straight and will not spread;

 

2. How to accurately tell the "friendly army" how many enemies are coming? !

  • Lighting the wolf smoke to inform - the enemy is coming, hurry up to support;
  • One cigarette represents one enemy, come five hundred enemies, light 500 wolf cigarettes, and burn yourself to death!
  • Optimization idea: light one cigarette, represent 1~10 enemies; light two cigarettes, represent 100; light three cigarettes, represent 1,000 people; light four cigarettes, represent 5,000 people; the problem is that it is impossible to "precisely" indicate how many people came. enemy.

30 binary conversion (two)

1. 1, 2, 4, 8, 16, 32, 64... According to the power of 2**n, to "accurately" represent the number of enemies;

 

2. Mutual conversion between "binary" and "decimal";

31 Explanation of small exercises on binary conversion

1. How to calculate the "binary" number of 342;

2. Use Python's built-in method -bin(n) to calculate;

32 ASCII and Binary

1. How to let the computer represent - words, symbols, letters and other characters? ! (Make a correspondence table - ASCII code table)

 

2. Convert text to binary;

  • The importance and necessity of assertions;
  • When writing a text, you need to use "punctuation marks" to break sentences;
  • Use spaces to break sentences, spaces are also binary;

 

3. In the ASCII code table, the maximum number of characters is 255 bits, and 8 bits are used to represent 1 character;

  • The space unit of each 0 or 1 is bit (bit), which is the "smallest representation unit" in the computer;
  • 8bit = 1bytes, is the "smallest storage unit" in the computer, 1bytes is abbreviated as 1B;

 

 

33 String encoded fireworks

1. There is only English in the ASCII code table, not our Chinese! As Chinese people expressed dissatisfaction, we created an "ASCII-like code table" ourselves.

  • Chinese character encoding: GB2312 was born, but it only represents part of Chinese, and only supports simplified Chinese;
  • GBK1.0, compatible with GB2312, the default encoding of Windows system is GBK;
  • GB18030, upward compatible;
  • Taiwan BIG5;

2. There are more than 200 countries and regions in the world, each of us has a set of "ASCII-like" code tables, which is messy; it is very troublesome to export software to each other;

 3. Then the problem comes again. I am dissatisfied with the Americans. Using Unicode has doubled my storage capacity. So, UTF-8 (variable-length character encoding) was born;

  • UTF-8 is a compression and optimization of Unicode;
  • Our party stipulates that the character encoding exported to my country must support GBK;

34 Encodings used in Python

1. The impact of character encoding on "programming";

  • Python2.x does not support Chinese by default;

 

 

  •  Python2.x to write Chinese, you need to specify (declare) the encoding format in the file header;

Command window modification code, CMD code modification method: https://jingyan.baidu.com/article/e75aca85440f01142edac636.html

 

35 Floating point and scientific notation

1. Data types in Python;

 

2. The introduction of real numbers;

  • rational numbers (finite or infinite recurring decimals);
  • irrational numbers (infinite non-repeating decimals);

3. Definition of floating point numbers and scientific notation;

  • Scientific notation;
  • Complex numbers (the concept z=a+bi in mathematics), represented in Python (5+4j);

 

36 The precision of floating point numbers

  • In Python, floating-point numbers can only store exactly 16 bits;

 

 

37 List types

 

38 List Types - Modify and Insert

39 List Types - Other Methods

 

40 List Exercise Questions Explained

 

41 List of exercises to explain 2

42 shades of copy

43 String Type Explanation

 

44 String type explanation 2

45 tuple type

 

46 hash functions

 

47 Dictionary types and properties

 

48 Detailed methods of dictionary types

 

49 Collection types

 

50 Relational Tests for Collection Types

 

51 hexadecimal operation

 

52 Why use hexadecimal

 

53 Hexadecimal and binary conversion

54 Character Encoding Review

How to save 55 characters to the hard disk

56 character encoding conversion

57 Python3 code execution process

58 Python3 code conversion syntax

59 Python3 determines the encoding type by looking at the encoding mapping table

60 Introduction to Python bytes type

61 Difference between Python3 and 2 strings

62 Python3 and 2 encoding summary

63 Job Requirements

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521184&siteId=291194637