-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-First test
55 lines (36 loc) · 1.01 KB
/
02-First test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
02-First test
1.Type 'python' in command line, we can open the python interaction console
symbol >>>
test:
>>> 100+100
200
>>> 6000*2
12000
>>> print(5)
5
>>> prin("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'prin' is not defined
>>> print("hello")
hello
>>> print('hello')
hello
>>> print('5'+"1000")
51000
>>> exit()
Under this circumstance, we can't save anything.
2. create a new file, text "print("hello world")", save as .py
go to the direction in console and run it
1) use 'python' as the key word to run
SuzydeMacBook-Pro:python suzy$ python hello.py
hello world
2) add '#!/usr/bin/env python3' on top of the file
run chmod a+x 02-hello.py
then we can run hello.py directly without keyword python
test:
SuzydeMacBook-Pro:python suzy$ chmod a+x hello.py
SuzydeMacBook-Pro:python suzy$ ./hello.py
hello world
SuzydeMacBook-Pro:python suzy$ ./hello.py
hello world!!!