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 错误与异常 此前,我们还没有开始着眼于错误信息.不过如果你是一 ...
随机推荐
- Py层次递进与文件修改大程序,模块,name与file
层次的递进与返回 #输入quit的时候返回上一阶层,输入exit退出所有的循环 tag=True while tag==True: level1=input('level1:') if level1= ...
- C#高级编程第11版 - 第七章 索引
[1]7.1 相同类型的多个对象 1.假如你需要处理同一类型的多个对象,你可以使用集合或者数组. 2.如果你想使用不同类型的不同对象,你最好将它们组合成class.struct或者元组. [2]7.2 ...
- 编码占用的字节数 1 byte 8 bit 1 sh 1 bit 中文字符编码 2. 字符与编码在程序中的实现 变长编码 Unicode UTF-8 转换 在网络上传输 保存到磁盘上 bytes
小结: 1.UNICODE 字符集编码的标准有很多种,比如:UTF-8, UTF-7, UTF-16, UnicodeLittle, UnicodeBig 等: 2 服务器->网页 utf-8 ...
- 扒一扒ELF文件
ELF文件(Executable Linkable Format)是一种文件存储格式.Linux下的目标文件和可执行文件都按照该格式进行存储,有必要做个总结. 目录 1. 链接举例 2. ELF文件类 ...
- 谁再把IDEA的Project比作Eclipse的Workspace,我就跟谁急
前言 你好,我是A哥(YourBatman). 有一个观点:若一个Java开发者能把IDEA玩得666,则技术一定不会差:但若玩不转IDEA(如不会设置.定制.解决日常问题.快捷键等等),那大概率水平 ...
- mysql高级day1
Mysql高级-day01 MySQL高级课程简介 序号 Day01 Day02 Day03 Day04 1 Linux系统安装MySQL 体系结构 应用优化 MySQL 常用工具 2 索引 存储引擎 ...
- Java中的fail-fast和 fail-safe 的区别
在我们详细讨论这两种机制的区别之前,首先得先了解并发修改. 1.什么是同步修改? 当一个或多个线程正在遍历一个集合Collection,此时另一个线程修改了这个集合的内容(添加,删除或者修改).这就是 ...
- c#的dllimport使用方法详解(Port API)
DllImport是System.Runtime.InteropServices命名空间下的一个属性类,其功能是提供从非托管DLL(托管/非托管是微软的.net framework中特有的概念,其中, ...
- Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from 这类问题的解决方法
最近换了台电脑,所以重新在IEDA上搭建Spring Boot环境,遇到一个问题,网上查了很久,又实践了一通,终于解决,这里把步骤详细记录下来. 问题描述:创建IDEA的Maven项目后,出现 Mav ...
- H - 看病要排队
看病要排队这个是地球人都知道的常识.不过经过细心的0068的观察,他发现了医院里排队还是有讲究的.0068所去的医院有三个医生(汗,这么少)同时看病.而看病的人病情有轻重,所以不能根据简单的先来先服务 ...