Here is the translated version of the previous code.
Original JavaScript Code:
brendan@LP50C:~/practice-linux$ cat app.js
let index = 0
const words = [
'๋ ์ข
๋ฃํด์ค',
'๋ถํ์ด์ผ, ์์ํ๊ฒ ํด์ค',
'Ctrl... ๊ทธ๋ฆฌ๊ณ ...',
'์ฟจ๋ญ',
'c ๋ฅผ ๋๋ฅด๋ฉด... ๋ผ',
'์๋ c t r l ์ด ์๋๋ผ',
'์ปจํธ๋กค ํค๋ฅผ ๋จผ์ ...',
'์ปจํธ๋กค ํค ์ด์์์ ์ปจํธ๋กค ์ปจํธ๋กค ์ปจํธ๋กค',
'์ฝ๋ก์ฝ๋ก',
'๋ ์ผ์ชฝ ์๊ฐ๋ฝ์ผ๋ก ์ ค ์๋',
'์ด์ฐ ์ข ์ฟจ๋ญ ๋๋ด๋ฌ๋ผ๊ณ '
]
setInterval(
() => {
console.log(words[(index++)%words.length])
},
1000
)
Run above java code using node.
brendan@LP50C:~/practice-linux$ node app.js
๋ ์ข
๋ฃํด์ค
๋ถํ์ด์ผ, ์์ํ๊ฒ ํด์ค
Ctrl... ๊ทธ๋ฆฌ๊ณ ...
์ฟจ๋ญ
c ๋ฅผ ๋๋ฅด๋ฉด... ๋ผ
์๋ c t r l ์ด ์๋๋ผ
์ปจํธ๋กค ํค๋ฅผ ๋จผ์ ...
์ปจํธ๋กค ํค ์ด์์์ ์ปจํธ๋กค ์ปจํธ๋กค ์ปจํธ๋กค
์ฝ๋ก์ฝ๋ก
๋ ์ผ์ชฝ ์๊ฐ๋ฝ์ผ๋ก ์ ค ์๋
์ด์ฐ ์ข ์ฟจ๋ญ ๋๋ด๋ฌ๋ผ๊ณ
๋ ์ข
๋ฃํด์ค
๋ถํ์ด์ผ, ์์ํ๊ฒ ํด์ค
Ctrl... ๊ทธ๋ฆฌ๊ณ ...
์ฟจ๋ญ
c ๋ฅผ ๋๋ฅด๋ฉด... ๋ผ
์๋ c t r l ์ด ์๋๋ผ
์ปจํธ๋กค ํค๋ฅผ ๋จผ์ ...
์ปจํธ๋กค ํค ์ด์์์ ์ปจํธ๋กค ์ปจํธ๋กค ์ปจํธ๋กค
^C
Now translated version and in Python Script.
brendan@LP50C:~/practice-linux$ cat app1.py
import time
import datetime
words = [
'Quit this operation.',
'Please give me a break.',
'To quit, ',
'Press Ctrl... and',
'c, OK?',
'No, don\'t press c, t, r, l',
'Press the Ctrl key first...',
'Press the Ctrl key, you idiot, not c, t, r, l keys',
'Sigh...',
'Move your left pinky finger to the bottom of your keyboard.',
'I beg you to press the Ctrl key and the c key combination.',
'Thank you my friend!'
]
for i in range(1000):
for word in words:
now = datetime.datetime.now()
date_time = now.strftime("%d/%m/%Y %H:%M:%S")
print(date_time)
print(word, end="\n")
time.sleep(1)
brendan@LP50C:~/practice-linux$ python3 app1.py
11/12/2022 12:11:44
Quit this operation.
11/12/2022 12:11:45
Please give me a break.
11/12/2022 12:11:46
To quit,
11/12/2022 12:11:47
Press Ctrl... and
11/12/2022 12:11:48
c, OK?
11/12/2022 12:11:49
No, don't press c, t, r, l
11/12/2022 12:11:50
Press the Ctrl key first...
11/12/2022 12:11:51
Press the Ctrl key, you idiot, not c, t, r, l keys
11/12/2022 12:11:52
Sigh...
11/12/2022 12:11:53
Move your left pinky finger to the bottom of your keyboard.
11/12/2022 12:11:54
I beg you to press the Ctrl key and the c key combination.
11/12/2022 12:11:55
Thank you my friend!
11/12/2022 12:11:56
Quit this operation.
^CTraceback (most recent call last):
File "/home/brendan/practice-linux/app1.py", line 25, in <module>
time.sleep(1)
KeyboardInterrupt
Disable the timedate for cleaner result:
brendan@LP50C:~/practice-linux$ cat app1.py
import time
words = [
'Quit this operation.',
'Please give me a break.',
'To quit, ',
'Press Ctrl... and',
'c, OK?',
'No, don\'t press c, t, r, l',
'Press the Ctrl key first...',
'Press the Ctrl key, you idiot, not c, t, r, l keys',
'Sigh...',
'Move your left pinky finger to the bottom of your keyboard.',
'I beg you to press the Ctrl key and the c key combination.',
'Thank you my friend!'
]
for i in range(1000):
for word in words:
print(word, end="\n")
time.sleep(1)
brendan@LP50C:~/practice-linux$ python3 app1.py
Quit this operation.
Please give me a break.
To quit,
Press Ctrl... and
c, OK?
No, don't press c, t, r, l
Press the Ctrl key first...
Press the Ctrl key, you idiot, not c, t, r, l keys
Sigh...
Move your left pinky finger to the bottom of your keyboard.
I beg you to press the Ctrl key and the c key combination.
Thank you my friend!
Quit this operation.
Please give me a break.
To quit,
Press Ctrl... and
^CTraceback (most recent call last):
File "/home/brendan/practice-linux/app1.py", line 21, in <module>
time.sleep(1)
KeyboardInterrupt