Python errors All In One
Python errors All In One
SyntaxError: invalid character in identifier

\u200b, ZERO WIDTH SPACE
https://stackoverflow.com/questions/14844687/invalid-character-in-identifier
SyntaxError: invalid syntax
if__name__ == "__main__":
# if 关键字,后面加空格
if __name__ == "__main__":

用于区分,如何执行 Python 模块

https://www.jcchouinard.com/python-if-name-equals-main/
# Python program to execute
# main directly
print ("Always executed")
if __name__ == "__main__":
# 模块, 被直接执行的时候
print ("Executed when invoked directly")
else:
# 模块,被 import 使用的时候
print ("Executed when imported")
https://www.geeksforgeeks.org/what-does-the-if-name-main-do/
# Suppose this is foo.py.
print("before import")
import math
print("before functionA")
def functionA():
print("Function A")
print("before functionB")
def functionB():
print("Function B {}".format(math.sqrt(100)))
print("before __name__ guard")
if __name__ == '__main__':
functionA()
functionB()
print("after __name__ guard")

https://stackoverflow.com/questions/419163/what-does-if-name-main-do
emoji bug

$ ls
# chmod 777 / chmod 755
$ chmod +x ./dict.py
# 可执行脚本
# #!/usr/bin/python3
$ ./dict.py
# 指定解释器
$ python3 ./dict.py
#!/usr/bin/python3
# 一行 OK
# dict = {'Name': 'xgqfrms', 'Age': 18, 'Class': 'First'}
# 多行错误
dict = {
'Name': 'xgqfrms',
'Age': 18,
'Class': 'First',
'Country': 'China ',
}
# 更新 Age
dict['Age'] = 23
# 添加信息
dict['School'] = "Python 教程"
print ("dict['Age']: ", dict['Age'])
print ("dict['School']: ", dict['School'])
print ("dict['Country']: ", dict['Country'])
https://www.runoob.com/python3/python3-dictionary.html
refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
Python errors All In One的更多相关文章
- Python Errors and Exceptions
1. python中的try{}catch{} 2. raise exception 3. try...except ... else.. 4. finally块 python中的异常处理的keywo ...
- arcgis python 异常处理
import arcpy in_features = "c:/base/transport.gdb/roads" try: # Note: CopyFeatures will al ...
- arcgis python 发送邮件
import arcgisscripting, smtplib, os, sys, traceback from email.MIMEMultipart import MIMEMultipart fr ...
- caffe2--Install
Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...
- caffe2--ubuntu16.04--14.04--install
Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...
- Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean
http://www.360doc7.net/wxarticlenew/541275971.html 一.什么是源码包软件? 顾名思义,源码包就是源代码的可见的软件包,基于Linux和BSD系统的软件 ...
- linux安装python3.*,更换Python2.*
下载并解压:Python-3.5.7.tgz [root@AH-aQYWTYSJZX01 python3]# ll total 20268 -rw-r----- 1 temp01 temp01 207 ...
- Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean 假目标
http://www.360doc7.net/wxarticlenew/541275971.html 一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 ...
- Python Tutorial 学习(八)--Errors and Exceptions
Python Tutorial 学习(八)--Errors and Exceptions恢复 Errors and Exceptions 错误与异常 此前,我们还没有开始着眼于错误信息.不过如果你是一 ...
随机推荐
- 树莓派安装 Ubuntu 20.04 LTS 碰壁指南
树莓派安装 Ubuntu 20.04 LTS 碰壁指南 设备 Raspberry 4B 4+32G 系统 Ubuntu 20.04 LTS 1.镜像下载与烧录 镜像下载地址:https://cdima ...
- 从零搭建一个IdentityServer——集成Asp.net core Identity
前面的文章使用Asp.net core 5.0以及IdentityServer4搭建了一个基础的验证服务器,并实现了基于客户端证书的Oauth2.0授权流程,以及通过access token访问被保护 ...
- spring restTemplate 进行http请求的工具类封装
本文为博主原创,未经允许不得转载: 1.对常用调用的方法进行封装: import org.springframework.http.HttpHeaders; import com.alibaba.fa ...
- 并发编程:Actors 模型和 CSP 模型
https://mp.weixin.qq.com/s/emB99CtEVXS4p6tRjJ2xww 并发编程:Actors 模型和 CSP 模型 ImportNew 2017-04-27
- 9.5 自定义包和可见性 go mod
the-way-to-go_ZH_CN/09.5.md at master · Unknwon/the-way-to-go_ZH_CN https://github.com/Unknwon/the-w ...
- windows IOCP 实践
关于 windows IOCP 有人说 windows IOCP 是 windows 上最好的东西. IOCP 是真正的异步 IO,意味着每次发起一个 IO 请求,该调用本身则立即返回, 而包括 IO ...
- windows命令行关闭IE代理
打开:reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnab ...
- 题解 CF620E 【New Year Tree】
有关dfs序的例题,需要有一定的位运算基础 题面 给定一个树,树上有颜色,将某一子树的颜色统一修改,求子树中颜色的数量 Solution 子树修改,子树求和,dfs序的知识(类似区间修改区间求和) 考 ...
- JVM 参数的设置及解析
JVM 参数的设置及解析 1.关于JVM配置: 2.Linux JVM设置: 1.关于JVM配置: 设置jvm内存的参数有四个: -Xmx 设置堆(Java Heap)最大值,默认值为物理内存的1/4 ...
- NATAPP--实现SSH内网穿透
NATAPP--实现SSH内网穿透 1. 关于Natapp 2. 使用Natapp 3. Natapp安装和配置 4. XShell连接 相关参考博文原文地址: CSDN:KevenPotter:NA ...