I tried to touch Python (installation) continued
--Japanese characters are garbled when connecting to a virtual machine with SSH. ――When I looked it up, I was surprised that the following article was in trouble! -What to do if garbled characters on CentOS under SSH environment
Virtual machine
#Status check → VC Keymap is us
$ localectl status
System Locale: LANG=ja_JP.utf8
VC Keymap: us
X11 Layout: n/a
#Updated VC Keymap to jp106(Run with sudo)
$ sudo localectl set-keymap jp106
#Check the status again → VC Keymap updated to jp106
$ localectl status
System Locale: LANG=ja_JP.utf8
VC Keymap: jp106
X11 Layout: jp
X11 Model: jp106
X11 Options: terminate:ctrl_alt_bksp
#Check if Japanese locale can be used → There is no ja in the first place! ??
$ localectl list-locales | grep -i ja
#Added Japanese locale
$ sudo localedef -f UTF-8 -i ja_JP ja_JP
#Make sure the Japanese locale is enabled
$ localectl list-locales | grep -i ja
ja_JP
ja_JP.utf8
Let's create and run the following program to learn the basic syntax.
Command execution
# .Create py file
$ vi test02.py
test02.py
print('Module loading')
def test():
print('Function: called test')
if __name__ == '__main__':
print('python-izm')
# print('Python ism')
test()
Command execution
#Created using Python commands.Run py file
$ python test02.py
Module loading
python-izm
Function: called test
UTF-8 is applied by default for character encoding of 3 series, so you do not have to be aware of it.
Python uses indentation for its block structure. Since {} is not used, an error will occur if the indentation is not consistent.
Command execution
# .Create py file
$ vi test03.py
test03.py
print('Module loading')
def test():
print('Function: called test')
#Execute only when the target program is started as a script
#Not executed when importing etc.
if __name__ == '__main__':
print('python-izm')
# print('Python ism')
test()
Command execution
#Created using Python commands.Run py file
$ python test03.py
File "test03.py", line 10
test()
^
IndentationError: unindent does not match any outer indentation level
IndentationError: unindent does not match any outer indentation level IndentationError: unindent does not match any outer indentation level
The error message that google teacher says is the above.
You only have to be careful about the block structure of the indent, I've touched the GO language before, so I didn't feel any discomfort.
As for the future flow, I will write an article if I can make something after implementing the basic and advanced editions! (Because it is easier to remember character strings and if statements than to write articles)
Recommended Posts