Install Python https://www.python.org/downloads/windows/i install it here on Windows, if other operating systems can be found separately
After the installation is complete, open the execution program and enter the first command
Print ("Hello world!") Note Because I use the new version here, so print after the parentheses, otherwise error
"Syntaxerror:missing parentheses in call to ' print '" mean in Python?
。
The following can be used to write a Python program, save after the click can be directly executed.
Generally in/lib/idlelib/idle
650) this.width=650; "src="%5c "title=" \ "python.jpg\" "alt=" Wkiom1mzuhjzu_ucaabh7tj6rvu897.jpg-wh_50 "/>
Here you can see the import OS
..
.. Multiple outputs only need to add the * number.
Os.system ("pause")//action file is paused after execution.
Import Random
Secret = Random.randint (1,100)
Guess = 0
Tries = 0
Print ("ahoy! I ' m the Dread priate Roberts, and I have a secret! ")
Print ("It is a number from 1 to 99.") I ' ll give you 6 tries. ")
Print (Secret)
While Guess!=secret and tries < 6://Note this colon
guess = int(input ("What's your Guess?")) //Note that your input is in the default character and cannot be compared to a number, which differs from earlier versions of Python. There are other things besides int (), such as float (), str (), and so on.
If guess < secret:
Print ("Too low, Ye scurvy dog!")
Elif Guess > Secret:
Print ("Too high,landlubber!")
Tries = tries + 1//note alignment, because there are no parentheses in Python, so judging the statement segment looks at these alignments.
if guess = = Secret:
Print ("avast! You got it! Found my secret,you did! ")
Else
Print ("NO more guess!")
Print ("The secret number was", secret)
Variable names can only start with letters and underscores, and no spaces in between can be basically the same as the C language variable names.
Use "" If you are using strings that span multiple lines.
Newer versions of Python no longer have to differentiate decimals when using division, Print (3/2) outputs 1.5
The print (2**5) Star represents the power of the subsequent number
Output 32
Self-increment self-decrement symbol + = =
>>> a=24
>>> B=float (a)
>>> b
24.0 strong to floating-point type.
Type (a) can display the types of a.
Int (56.78) is rounded down to 56
somebody = input ("Enter your Name:")//Note This allows you to enter your name. On the same line as the prompt
Print ("Hi", Somebody, "How is you today?")
Import Urllib.request
File = Urllib.request.urlopen (' http://192.168.18.110/') //Note Urllib.urlopen changed to Urllib.request.urlopen
Message =file.read ()
Print (message)
This article is from the "Gusu City" blog, make sure to keep this source http://ji123.blog.51cto.com/11333309/1964036
Python first day