The purpose of writing this blog is to record some of the problems of learning Python. Today, it is also the first day of new recruits, but also record the drip of daily life. Let's see how long I can hold on. Morning, get up, wash, hurried to the company, the result is still late, but the boss is not, and then is installed, installed in the process of knowing the company in the morning to work time is very flexible, from 8:30 to 9:30 can, just affect your work time, heart dark cool. But it's a little scary to be late for a 50 deduction. And start the day's nonsense. 5:30 P.M. on time to slip. Back to start the installation of Python (originally last night on the next, but for a long time, found that Python now has a 2.x,3.x version. As the choice of the late patients with difficulty, of course, the next half a day, and finally hurriedly know to check, most people say that the choice of 3.x, it is good to know Dafa. By the way, the public WiFi, the midnight speed is really a bit clumsy. Forgot to check the automatic configuration environment variable when installing. Also lazy Baidu how to match environment variables, uninstall reinstall. OK, the installation is finally finished. Next, start by pressing the tutorial to start with a letter-by-letter knock on the first line of Python code print ("hello,world! "); I started to play a semicolon, but look at the tutorial and see that there are no rating numbers. It's a big surprise. God, he didn't want a semicolon; so hurriedly ferry: If you want to write more than one sentence in a row, you must separate each statement with a semicolon, or Python will not recognize the interval between statements:
- # Separating statements with semicolons
- X=1; Y=1; Z=1
The 2nd line of code has 3 assignment statements, and the statements need to be separated by semicolons. If you do not separate the statement, the Python interpreter will not be able to interpret it correctly, prompting a syntax error:
- Syntaxerror:invalid syntax
The Note semicolon is not a python-recommended symbol, and Python tends to use line breaks as a separator for each statement, and simple and straightforward is the Python syntax feature. The usually writes only one statement in a row, which makes it easier to read and understand the program. The way to write multiple statements on one line is bad habit. Python also supports multiple lines of writing a statement, and Python uses "\ \" as a newline character. In practice, it is very common for a statement to be written in multiple lines. Then knock some weird code: a=1.a, sure enough to execute the times wrong.
Next follow the tutorial under a notepad++, write a "HelloWorld" py file, is to execute the file, and then use the command line to enter the location of the file, and directly enter the filename (including the suffix), decisive return, I saw the magic of the HelloWorld (PS: At the beginning I forgot how to enter the designated folder, the ferry: the original CD your folder path), the heart wants Python so much. The contents of the file are then changed to 100+200, and then the command line executes, and the result is nothing. But in the IDE can output results, check the original is in command-line mode to execute the PY file, the output must be with print, and in the IDE called Python interactive mode, can directly output 100+200 results. There's a lot of crap. The young couple in the kitchen are eating well, eh.
June 29 Night Notes |