当前位置:网站首页>Can the variable name be in Chinese? Directly fooled people
Can the variable name be in Chinese? Directly fooled people
2022-07-25 14:06:00 【Ride Hago to travel】
This is how it started 
morning , Xiaobian went to the library to study as usual , When passing by a girl , Just took a look , Found that she was also learning python, But the two lines of code presented on the screen directly confused people ! The contents are as follows :
User input = input(' Please enter the content :')
print( User input )

Wanted ,python Chinese can do variable names ?

In fact, I really wanted to tell her about this problem at that time , But I'm afraid I'm weak in talent and learning , What if it really works ? therefore , I found a small corner where there was no one , Prepare to try it yourself !
I took the two lines of code intact , Found that it really works , Because I have never done this before !
But I still don't believe it , I also tested the following code
①
character string = ' Next to the Lao wang '
Tuples = (' ha-ha ', ' Hee hee ', ' Hello ', ' Yes ')
list = [' ha-ha ', ' Hee hee ', ' Hello ']
Dictionaries = {
' full name ': ' Lao Wang ', ' Age ': ' Twenty five years old ', ' Gender ': ' male '}
aggregate = {
' Two ha ', ' Alaska ', ' Samoye '}
print( character string )
print( Tuples )
print( list )
print( Dictionaries )
print( aggregate )
Next to the Lao wang
(' ha-ha ', ' Hee hee ', ' Hello ', ' Yes ')
[' ha-ha ', ' Hee hee ', ' Hello ']
{
' full name ': ' Lao Wang ', ' Age ': ' Twenty five years old ', ' Gender ': ' male '}
{
' Two ha ', ' Samoye ', ' Alaska '}
②
Lao Wang's age = 18
User input = input(' Please enter the age of Lao Wang you guessed :')
if int( User input ) == Lao Wang's age :
print(' Congratulations on your guesses !!!')
elif int( User input ) > Lao Wang's age :
print(' Your guess is too old !!')
else:
print(' Your guess is younger !!!')
Please enter the age of Lao Wang you guessed :23
Your guess is too old !!

Even though pycharm The color shown in is not quite right , But there is no problem in operation .
So here comes the question , Is this really the right thing to do ?
The answer is No , Don't fit . Not to mention anything else , In the process of compiling the above code by Xiaobian himself , feel , The frequency of switching input method is significantly increased ! In fact, this is only secondary !
The main thing is here → Xiaobian is here to remind you ,python Do not name the variable name in Chinese ( Pinyin is not suitable ), Don't name it in Chinese ( Pinyin is not suitable ), Don't name it in Chinese ( Pinyin is not suitable , Try not to appear Chinese in the code )!!! Name in English , It's best to see the famous uprising , Let others guess at a glance , About what it means !( Such as : Name name, Age use age And so on )
because python In recent years, the popularity has been increasing , Also more and more robust , flexible , Efficient , But don't misinterpret it by naming variables in Chinese ’ Uncle GUI ‘ The original intention of !
边栏推荐
- ~4.1 sword finger offer 05. replace spaces
- CSV文本文件导入excel的四种方法
- einsum(): operands do not broadcast with remapped shapes [original->remapped]: [1, 144, 20, 17]->[1,
- Interpretation of featdepth self-monitoring model for monocular depth estimation (Part I) -- paper understanding and core source code analysis
- Mlops column introduction
- Redux usage and analysis
- Xintang nuc980 set DHCP or static IP
- wangeditor 富文本编辑器
- From fish eye to look around to multi task King bombing -- a review of Valeo's classic articles on visual depth estimation (from fisheyedistancenet to omnidet) (Part I)
- Brush questions - Luogu -p1046 Tao Tao picking apples
猜你喜欢

Advantages of wireless relay acquisition instrument and wireless network for engineering monitoring

Brush questions - Luogu -p1085 unhappy Jinjin

Construction and practice of yolov7 in hands-on teaching

Brush questions - Luogu -p1152 happy jump

Internal error of LabVIEW

~4.1 sword finger offer 05. replace spaces

Setting of parameter configuration tool for wireless vibrating wire collector

Oka pass rights and interests analysis is the best choice to participate in okaleido ecological construction

Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output

Day1: 130 questions in three languages
随机推荐
[force buckle] 645. Wrong set
Package management apt, dpkg
Okaleido生态核心权益OKA,尽在聚变Mining模式
Hyperautomation for the enhancement of automation in industries
Data analysis interview records 1-5
Experiment the Arduino code of NTP network timing alarm clock with esp32+tm1638
CDA level1 multi topic selection
命名空间与库
Detailed explanation of how R language converts large Excel files into DTA format
Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]
OKA通证权益解析,参与Okaleido生态建设的不二之选
~5 new solution of CCF 2021-12-2 sequence query
Basic theory of monocular depth estimation and paper learning summary
ADB connects to Xiaomi mobile phone via Wi Fi
Goldfish rhca memoirs: cl210 management storage -- object storage
telnet远程登录aaa模式详解【华为eNSP】
Realize a family security and environmental monitoring system (II)
Gartner 2022 top technology trend: Super automation
Nuc980 set up SSH xshell connection
MySQL 01: Source command