当前位置:网站首页>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 !
边栏推荐
- DNS resolution error during windows unbutu20 lts apt, WGet installation
- 科隆新能源IPO被终止:拟募资6亿 先进制造与战新基金是股东
- [platform IO compile hifive1 revb] * * * [.pio\build\hifive1 revb\src\setupgpio.o] solution to error 1
- 2271. 毯子覆盖的最多白色砖块数 ●●
- Xintang nuc980 set DHCP or static IP
- CDA level Ⅰ 2021 new version simulation question 1 (with answers)
- IDEA设置提交SVN时忽略文件配置
- 苹果手机端同步不成功,退出登录,结果再也登录不了了
- 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 -p1059 clear random number
猜你喜欢

Tm1637 four digit LED display module Arduino driver with second dot

Experiment the Arduino code of NTP network timing alarm clock with esp32+tm1638

Alibaba mqtt IOT platform "cloud product circulation" practice - the two esp32 achieve remote interoperability through the IOT platform

NUC980 设置SSH Xshell连接

Engineering monitoring multi-channel vibrating wire sensor wireless acquisition instrument external digital sensor process

redis集群的三种方式

Multidimensional pivoting analysis of CDA level1 knowledge points summary

Data analysis business core

Pytest.mark.parameterize and mock use

Word set paste to retain only text
随机推荐
maya建模练习
Brush questions - Luogu -p1146 coin flip
苹果手机端同步不成功,退出登录,结果再也登录不了了
金鱼哥RHCA回忆录:CL210管理存储--管理共享文件系统
MySQL and Navicat installation and stepping on pits
What should I do if the high-level MySQL server cannot be installed and I forget the password (MySQL 8.0.29)?
Problems and extensions of the monocular depth estimation model featdepth in practice
Pytest.mark.parameterize and mock use
OKA通证权益解析,参与Okaleido生态建设的不二之选
word设置粘贴仅保留文本
Common problems of wireless relay acquisition instrument
Business analysis report and data visualization report of CDA level1 knowledge point summary
Redux usage and analysis
Advantages of wireless relay acquisition instrument and wireless network for engineering monitoring
opencv视频跟踪「建议收藏」
Introducing mlops interpretation (I)
MySQL 01: Source command
Wangeditor rich text editor
What you must know about data engineering in mlops
swiper 一侧或两侧露出一小部分